Java 7 one line solution
List<String> lines = Files.readAllLines(Paths.get("file"), StandardCharsets.UTF_8);
or
String text = new String(Files.readAllBytes(Paths.get("file")), StandardCharsets.UTF_8);
More Related Contents:
- File I/O Concept [closed]
- How do I create a Java string from the contents of a file?
- How to read all files in a folder from Java?
- How do I get the file extension of a file in Java?
- Quickly read the last line of a text file?
- byte[] to file in Java
- File exists and IS directory, but listFiles() returns null
- java IO to copy one File to another
- java read file from network device
- How to break a file into pieces using Java?
- Test if a file is an image file
- In Java, how do I parse XML as a String instead of a file?
- Getting the filenames of all files in a folder [duplicate]
- Do I need to close() both FileReader and BufferedReader?
- Create a new line in Java’s FileWriter
- How to get absolute path to file in /resources folder of your project
- Determine if two files store the same content
- How do I use Java to read from a file that is actively being written to?
- How to read a file from a jar file?
- What is the best/simplest way to read in an XML file in Java application? [closed]
- Access resource files in Android
- Accessing files with spaces in filename from Java
- What is the best way to generate a unique and short file name in Java
- How to send byte[] as pdf to browser in java web application?
- adding progress bar to each table cell for file progress – Java
- Find files in a folder using Java
- How to read a text file directly from Internet using Java?
- Java Scanner doesn’t wait for user input [duplicate]
- difference between flush and close function in case of filewriter in java
- Is there a java library equivalent to file command in unix