In java under Windows, how do I find a redirected Desktop folder?

后端 未结 2 790
夕颜
夕颜 2020-11-29 11:04

I know using .NET languages such as C#, one can do something like

Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

to

相关标签:
2条回答
  • 2020-11-29 11:55
    public class Sample {
       public static void main(String[] args) {    
          String desktopPath =System.getProperty("user.home") + "\\"+"Desktop";
          String s = "\"" + desktopPath.replace("\\","\\\\") + "\\\\" +"satis" + "\"";
    
          System.out.print(s);
          File f = new File(s);
    
          boolean mkdir = f.mkdir();
          System.out.println(mkdir);
       }
    }
    
    0 讨论(0)
  • 2020-11-29 12:07
    FileSystemView filesys = FileSystemView.getFileSystemView();
    
    File[] roots = filesys.getRoots();
    
    filesys.getHomeDirectory()
    
    0 讨论(0)
提交回复
热议问题