Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
557 views
in Technique[技术] by (71.8m points)

windows - Getting My Documents path in Java

I need to find my documents path using Java. The following code doesn't give me "accurate" loation

System.getProperty("user.home");

What should be the other way around?

P.S: I don't want to use the JFileChooser Dirty trick.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's easy, JFileChooser finds it for you

new JFileChooser().getFileSystemView().getDefaultDirectory().toString();

I hope this helps someone


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...