The following method generates a txt containing certain information:
public static void gravarIp(String ip)
{
try {
File arquivo = new File("ip.txt");
FileOutputStream fos = new FileOutputStream(arquivo);
String texto = ip;
fos.write(texto.getBytes());
fos.close();
atualizarPortal(ip);
}
catch (IOException e)
{
e.printStackTrace();
}
}
However, this txt is being generated in the place where the statement is executed:
c:\>java -cp c:\users\fabio\desktop EnviarIp
That is, if the above statement is executed and I am in the root of c: txt will be generated there. How do I generate the txt in the same root as the SendIp file without specifying the absolute path in the source code?