I have stored a flatfile (.txt
format) in DB as BLOB and retrieving it using JPA
like below.
@Lob
@Column( name="TXT_FILE")
private byte[] txtFile;
Could you please suggest, how can I get the content of this text file from this byte[]
?
Well, I'm supposing that you didn't persist the whole file, but only it's content.
If so, you could just read it by doing a new String(yourObject.getTxtFile(), "UTF-8")
Note that used UTF-8 as the encoding pattern. So you'll need to store data with it too.