The Artima Developer Community
Sponsored Link

Java Answers Forum
setCurrentDirectory from a string?????

1 reply on 1 page. Most recent reply: Oct 23, 2008 6:46 AM by Jesper de Jong

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Eric Lollathin

Posts: 1
Nickname: krazykoote
Registered: Oct, 2008

setCurrentDirectory from a string????? Posted: Oct 17, 2008 10:00 AM
Reply to this message Reply
Advertisement
Here is what I have:

private File defaultDirectory;

JFileChooser fcScholarNet = new JFileChooser(defaultDirectory);
fcScholarNet.showOpenDialog(StaffordLoanCompare .this);
File file = fcScholarNet.getSelectedFile();
defaultDirectory = fcScholarNet.getCurrentDirectory();
tfldScholarNetFile.setText(file.getPath());

Once the first file is picked I can set the default directory through .getCurrentDirectory() but how do I initialize or change my default/home directory to, for example: C:\Documents and Settings\ericl\Desktop

Thanks for the help?

Eric.


Jesper de Jong

Posts: 6
Nickname: 56437
Registered: Jun, 2008

Re: setCurrentDirectory from a string????? Posted: Oct 23, 2008 6:46 AM
Reply to this message Reply
You create a File object out of a string by simply using the constructor:
private File defaultDirectory = new File("C:\\Documents and Settings\\ericl\\Desktop");
Lookup the API documentation of class java.io.File.

Flat View: This topic has 1 reply on 1 page
Topic: How to do JUnit Testing in Java Previous Topic   Next Topic Topic: Convert type to type

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use