I am trying to read the content of a textfile in Java using BufferedReader. However, only the first line is being retrieved.
Here's the code:
public String myFile(String file)
{
String dataInTextFile = "";
try
{
BufferedReader fileInput = new BufferedReader(new FileReader(file));
try
{
dataInTextFile = fileInput.readLine();
}
catch (IOException e)
{
System.out.println(e);
}
}
catch (FileNotFoundException e)
{
System.out.println(e);
}
return dataInTextFile;
}