OO-Snippets: writing to outputstream

Commons

Keywordsoutputstream
LanguageOOBasic
ApplicationOffice
AuthorsTom Schindl
Christian Junker (initial)
Supported Versions
Supported OS
Question How can I write to outputstream
Answer

Code-Snippet-Listing (snippet-source)

Dim content = "Hello World!"
fileAccessService = createUnoService("com.sun.star.ucb.SimpleFileAccess")
textOutputStream = createUnoService("com.sun.star.io.TextOutputStream")

 If fileAccessService.exists(SaveFileName) Then
 	If fileAccessService.isReadOnly(SaveFileName) Then
        MsgBox "Could not write to file: " & SaveFileName
 		Exit Function
	End If
 End If
 'now open the file..
 outputStream = fileAccessService.openFileWrite(SaveFileName)		

 outputStream.truncate()
 textOutputStream.setOutputStream(outputStream)
 textOutputStream.writeString(content)

 'Close the Xml File, no writing possible anymore
 textOutputStream.closeOutput()

'msgbox "xml saved under: " & SaveFilename

Changelog

DateUserModification
2005-02-04tomsontomInitial version

and