Reading a whole file at once

suggest change
File f = new File(path);
String content = new Scanner(f).useDelimiter("\\Z").next();

\Z is the EOF (End of File) Symbol. When set as delimiter the Scanner will read the fill until the EOF Flag is reached.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents