I'm trying to learn how to use read line by line from a text file. Even though I put the txt file in the same src, the console always shows the error as - No such file or directory.
public class ddd {
public static void main(String[] args) {
FileInputStream fis = null;
BufferedReader reader = null;
try {
fis = new FileInputStream("/dd/src/com/dd/input.txt");
reader = new BufferedReader(new InputStreamReader(fis));
System.out
.println("Reading File line by line using BufferedReader");
String line = reader.readLine();
while (line != null) {
System.out.println(line);
line = reader.readLine();
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
try {
reader.close();
fis.close();
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
}