Kev
Kev

Reputation: 316

Java Read binary record into String

We are storing uploaded text files in a SQL server data. The field type is image.

The file upload and download correctly, what I want to do now is load the actual text content into a String variable directly from the database record.

Can anyone advise on how to do this please?

Upvotes: 0

Views: 589

Answers (1)

Thomas
Thomas

Reputation: 88707

Depends on how you read the data from the db. If you get a byte array, you could use new String(bytes);

Btw, why don't you use the CLOB datatype (or the equivalent for your server) for the field? This should normally cause the Java driver to return the String directly.

Upvotes: 3

Related Questions