Hi,
I found a problem writing to a file:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
Public Sub Command1_Click()
Dim fileName As String = System.getenv("tmp") & "\myFile.txt"
Dim f As VBFileHandler = Open(fileName, Output, Write, Shared)
Dim i As Integer
Dim cnt As Integer = 0
Dim res As Boolean
For i = 1 To 100
res = f.writeString(cnt & ": neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, " & _
"consectetur, adipisci velit, sed quia non numquam eius")
cnt = cnt + 1
If Not res Then
Debug.Print "premature exit at line " & cnt
End If
Next i
f.close
Debug.Print cnt & "Lines written to " & fileName
End Sub
|
The file ends up with just one line of text.
Only the last line is written properly.
The first 99 lines are ignored/skipped.
The writeString always returned a true status.
The source code in the Jabaco framework:
|
Jabaco Source
|
1
2
3
4
5
6
|
Public Function writeString(s As String) As Boolean
If myOutput = Nothing Then Exit Function
If myMode <> Append Then myOutput.getChannel.truncate 0
myOutput.write s
writeString = True
End Function
|
My impression is that "truncate 0" discards all but the last line of text.
The workaround for the time being is something like this:
|
Source code
|
1
2
3
4
5
6
7
|
Private myWriter As java#io#PrintWriter
myWriter = New java#io#PrintWriter(New java#io#BufferedWriter(New java#io#FileWriter(f)))
myWriter.println cnt & ": neque porro quisquam est, ..."
myWriter.close
|
Anny comments?
Greetings!
A1880