Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import java.lang.*;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- public class loadFile {
- //Load a file into a string
- // filePath example: "C:\\temp\\myFile.txt"
- public String loadFile(String filePath)throws FileNotFoundException, IOException
- {
- // Load the file
- StringBuilder stringBuilder = new StringBuilder();
- BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath) );
- try
- {
- String line = null;
- while( ( line = bufferedReader.readLine()) != null)
- stringBuilder.append(line + System.getProperty("line.separator") );
- bufferedReader.close();
- }
- catch(IOException e){
- e.printStackTrace();
- }
- return stringBuilder.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement