0
I’m working on a web project and I’m having a problem with files(java.io.File
). The problem is only when running the web application, if it is Java Application
the problem does not exist.
When instantiating a file, new File("diretorio");
, his path gets C://Windows/System32/diretorio
, so I can’t do anything, maybe because I don’t have Windows privileges.
"I solved the problem by "passing new File("C://Users/myName/diretorio")
, but I did not like the solution, I wanted to do automatic, take the path of the application itself, for example, since I am developing in my machine and after the deploy, as it is... I do not know.
Any hint?
Here’s the part of the project I’m having the problem with, a bean jsf.
My vision calls the method addFile()
so I can save the file I get from the vision. Everything is functional, but I have to pass the path as I said before, the way it is in the code below, the path is for Windows System32 folder.
Java bean.
@ManagedBean
@ViewScoped
public class Bean {
//ATRIBUTOS E LÓGICAS DE NEGÓCIO
public void addFile() {
File temporario = new File("temporario");
//LÓGICA DE NEGÓCIO
}
}