I have a Configuration package where I have a Config.java class and a config.txt file that I want to read.
Config.java
public class Config {
public String obtenerConfig(){
String texto = "";
try {
BufferedReader bf = new BufferedReader(new FileReader("config.txt"));
String temp = "";
String bfRead;
while((bfRead = bf.readLine()) != null)
temp = temp + bfRead;
texto = temp;
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
return texto;
}
But when you run it, it tells me that it could not find the file.
If I put the full path ("C: \ Documents \ blabla \ config.txt") instead of ("config.txt") it works, but it does not work that way.
Here is a photo so they can see that they are both in the same place.
Thank you!