Quantcast
Viewing all articles
Browse latest Browse all 36

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

Based on @erickson`s answer, you can use:

public String readAll(String fileName) throws IOException {    List<String> lines = Files.readAllLines(new File(fileName).toPath());    return String.join("\n", lines.toArray(new String[lines.size()]));}

Viewing all articles
Browse latest Browse all 36

Trending Articles



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