I have a method that receives a path to create a file in it and of course the directory I do it this way.
public static File createTempFile(String exteString, String nombre, String path) throws IOException {
try {
File file = new File(path + "\\" + nombre + exteString);
//--
Path toCreatePath = Paths.get(file.toURI());
if (!Files.exists(toCreatePath)) {
Files.createDirectories(toCreatePath);
}
return file;
} catch (IOException e) {
System.out.println(ReportLog.getErrorBuilder(new Object(), e));
}
return null;
}
My problem is that I need to somehow hide this directory , that is, it cannot be seen by the user , since it will contain secret information.
(not explicitly confidential information only non-redundant information for the user)
I think it is possible since the class Files
contains the method isHidden
but I still don't know how to tell the directory that it is hidden.
I'll give you an example
java.nio
that I found on this site :You will have to be careful if what you want is multiplatform.
That's right, you can indicate the attribute
:hidden
using the setAttribute() method in the documentation there is the example for this, applied to your function it would only beisHidden() only returns a boolean value to define if your attribute is present
Another option besides the one commented by @Dev.Joel (Java 7+):
is by using the attrib command using
Runtime.exec()
(Java 6-):