Repository where I mostly put random python scripts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

44 lines
968 B

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Simple class for reading files as strings.
*
* @author Jeffery Russell
*/
public class FileReader
{
public static String readFile(String filePath)
{
String fileContent = new String();
try
{
BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath)));
String line;
while ((line = br.readLine()) != null)
{
fileContent = fileContent.concat(line);
}
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
return fileContent;
}
public static void main(String[] args)
{
System.out.println("Test");
System.out.println(FileReader.readFile("./testData/data1.txt"));
}
}