Are you looking for customized advices? Click here to contact the expert!
by
0
5
2,286
2
Top 1% !
Famous
Easy-to-find
Specified
OpenSource
Popularity: 7357th place
Created
Modified Jan 10, 2017
JVMjre7
Languagejava
LicenseMIT_X11

Read file in Java

Efficient way to read file in Java using Files class
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1618428/Read-file-in-Java?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
import java.nio.file.Files; import java.nio.file.Paths; public static String readFile(String path) throws Exception { if (isNullOrEmpty(path)) { return ""; } return new String(Files.readAllBytes(Paths.get(path))); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus