i have a method, which should return a string from a text file. But it returning null. Could you please help me to figure this one out? Thank you!
Here is the code
public String findFile()
{
String line = "";
try
{
File myDir = new File("files");
File myFile = new File(myDir, "ISBN 123-654.txt");
BufferedReader br = new BufferedReader(new FileReader(myFile));
while ((line = br.readLine()) != null)
{
System.out.println(line + "1");
}
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println(line+"2");
return line;
}
String line should hold a text like: H:\Java\workspace\LMS\files\book.jpg
man