Probably converting a stream or file to String is one of the most common question asked when one starts using Java. Out of different solutions, the common one is to use BufferedReader
.
Recently I stumbled upon a java weblog, which suggested following one liner cool trick :
String text = new Scanner( source ).useDelimiter("\\Z").next();
Related posts
Feed
- India
- World
- Live
- Cricket News
This site uses cookies. These cookies come mainly from third party library used at this site(Google/Jetpack/etc). By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here Cookie Policy
To find out more, including how to control cookies, see here Cookie Policy