Why am I getting this error while trying to use jRTF library ?
java.lang.IllegalArgumentException: expected receiver of type com.tutego.jrtf.Rtf, but got java.lang.Class<com.tutego.jrtf.Rtf>
Here is my code
B4X:
Sub jrtf2java
Dim mjrtf As JavaObject
mjrtf.InitializeStatic("com.tutego.jrtf.Rtf")
Dim RtfText As JavaObject
RtfText.InitializeStatic("com.tutego.jrtf.RtfText")
RtfText.RunMethodjo("bold",Array( "Hello RTF")).RunMethod("toString",Null)
Dim writer As JavaObject
writer.InitializeNewInstance("java.io.FileWriter",Array(File.Combine(File.DirRootExternal,"mout.doc"),False))
mjrtf.RunMethodJO("out",Array(writer))
End Sub
The error is raised on the last line
mjrtf.RunMethodJO("out",Array(writer))
I am not sure .
Here is a copy of library documentation :
out
public void out(java.lang.Appendable out)
Writes the RTF document and send the output to an Appendable. This method closes the Appendable after writing if its of type Closeable.
Parameters:
out - Destination of this RTF output.
out
public java.lang.CharSequence out()
Returns the RTF document as a CharSequence.
Returns:
The RTF document.
Sub jrtf2java
Dim mjrtf As JavaObject
mjrtf.InitializeStatic("com.tutego.jrtf.Rtf")
Dim RtfText As JavaObject
RtfText.InitializeStatic("com.tutego.jrtf.RtfText")
RtfText.RunMethodjo("bold",Array( "Hello RTF")).RunMethod("toString",Null)
Dim writer As JavaObject
writer.InitializeNewInstance("java.io.FileWriter",Array(File.Combine(File.DirRootExternal,"mout.doc"),False))
mjrtf.RunMethodJO("rtf",Null).RunMethodJO("out",Array As Object(writer))
End Sub