Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String fileToRead = "path-to-file"; //path to file in the fs
- //reads the text file line by line
- BufferedReader reader = new BufferedReader(new FileReader(fileToRead));
- String curLine = null; //current line string
- StringBuilder strBuilder = new StringBuilder(); //using stringbuilder to slowly build the string by appending lines
- while ((curLine = reader.readLine()) != null) { //while there are more lines
- strBuilder.append(curLine); //append lines to StringBuilder
- }
- String input = strBuilder.toString(); //converting strBuilder to string
- return input; //and return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement