Hey guys,
First, i'm using Ubuntu! :)
I need some help here, I built a Java App, i want to set a default path tree, like this:
> cd /anyDirectory/meuRestaurante
> ls
bin/ data/
> cd bin
> ls
meuRestaurante.jar
> cd ..
> cd data
> ls
Cartoes.txt Clientes.txt
I want that my Java App save these txt's files on /data
directory, while is on /bin
directory.
Exctaly, how should be if i use these functions to read/save the txt's files.:
public static String readFile(String fileName) {
try {
File file = new File("."+fileName);
FileReader reader = new FileReader(file);
BufferedReader in = new BufferedReader(reader);
String string;
String returnString = "";
while ((string = in.readLine()) != null) {
returnString = "" + returnString + string;
}
in.close();
return returnString;
} catch (IOException e) {
System.err.println("readFile " + e.getMessage());
return null;
}
}
public static boolean writeFile(String fileName, String newContent){
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fileName, true));
out.write(newContent);
out.close();
return true;
}catch(IOException e){
System.err.println("writeFile " + e.getMessage());
return false;
}
}
How should be the fileName
?
Anyone has a tip ?