Dear community members,
I have a small problem with the following code. I think it should open the explorer in the C:\Users\Me\AppData\Local\Temp\ directory. However that does not work, actually nothing happens. No errors.
I have used the following code:
import java.awt.Desktop; import java.io.File; import java.io.IOException; public class Main { public static void main(String[] args) { try { Desktop.getDesktop().open(File.createTempFile("abcd", ".temp").getParentFile()); } catch (IOException e) { e.printStackTrace(); } } } If I replace it with a normal file, like new File("C:\"), then it does work. Can someone explain to me why it does not work?
PS: guys I forgot to tell you I also tried it with some characters like "abcd", it still gives nothing and shows nothing!
File.createTempFile(...).getParentFile()evaluate to? (That is, would it "work" if using that value, as a literal. If it is not expected, then that is where to look. If it is as expected, but doesn't open, then that is where to look. Isolate the problem using an iterative process.)