Quantcast
Channel: How do I create a Java string from the contents of a file? - Stack Overflow
Viewing all articles
Browse latest Browse all 36

Answer by jamesjara for How do I create a Java string from the contents of a file?

$
0
0

You can try Scanner and File class, a few lines solution

 try{  String content = new Scanner(new File("file.txt")).useDelimiter("\\Z").next();  System.out.println(content);}catch(FileNotFoundException e){  System.out.println("not found!");}

Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>