Quantcast
Viewing all articles
Browse latest Browse all 36

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

User java.nio.Files to read all lines of file.

public String readFile() throws IOException {        File fileToRead = new File("file path");        List<String> fileLines = Files.readAllLines(fileToRead.toPath());        return StringUtils.join(fileLines, StringUtils.EMPTY);}

Viewing all articles
Browse latest Browse all 36

Trending Articles



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