← servoy magazine

[Tip] Blob to string

  • Tips

by Karel Broer
Free Colours

Wouldn't it be great to get the (string) content of a binary file that is saved in a blob without creating a temp file first? It is possible!

For example: RTF document is saved in 'media_field_rtf'.
Get the content of the rtf in a var:

var text = ''
text = new java.lang.String(media_field_rtf)

You can do the same with every binary file in a blob; think about what you can do now with .XML, .HTML or .TEXT files!

Comments (3)

Harjo Kompagnie
Cool tip, Karel! Thanks.
David Workman
Yea, this tip rocks Karel. Worth a beer...maybe two beers...
John Sanderson
Be careful not to create String objects of large binaries. Maybe it would be better to stream this stuff out to disk ?