Quantcast
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?

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