How to convert String to Reader in java

Use java.io.StringReader: return new StringReader(string);.

Next time you need a reader, you can check the “Direct known subclasses” of the Reader class. Same goes for InputStream, etc. The place to start is the javadoc – it contains quite a lot of useful information.

But for your task at hand, you’d better follow Jon Lin’ advice of simply using a FileReader. There is no need to go through String. (For that, my advice from the previous paragraph applies as well)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)