简体   繁体   中英

How to select “My Documents” path to save a file

I want to do that:

JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(System.getProperty(**MY DOCUMENTS PATH **)));

All I want to do is to put the "My Documents" path, that it changes in different windows versions, but I don't know how to do it.

I can't use a "literal path" I need a relative path because this application is going to work on all windows versions and I can't use literal paths.

据我所知,这是所有Windows版本的“我的文档”路径:

String myDocumentPath = System.getProperty("user.home") + "Documents";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM