aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Accessing files in NetBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Accessing files in NetBeans" Watch "Accessing files in NetBeans" New topic
Author

Accessing files in NetBeans

Jack Mullaly
Greenhorn

Joined: Jun 07, 2006
Posts: 14
How do I read data from files which are outside the Netbeans project?

For example I am tring to acces a file from another Project called "Thinking" called "RS.txt" its Absolute path being C:\JavaPrograms\Thinking\RS.txt.

I type this File file = new File("JavaPrograms.Thinking.RS.txt");

I get a File Not Found Exceptions.

Learning this Netbeans is extra work, besides learning Java.
Please help.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Jack,
If you call new File() without specifying a path, the IDE uses the current working directory. I don't know where that is for NetBeans. You can find out by writing:
System.out.println(file.getPath());


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jack Mullaly
Greenhorn

Joined: Jun 07, 2006
Posts: 14
Jeanne,
How do you usually specify the path for a file in an IDE?
I tried this: File file = new File("JavaPrograms.Thinking.RS.txt");
Thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29220
    
135

Jack,
I usually use an absolute path, so I would say:
File file = new File("C:\\JavaPrograms\\Thinking\\RS.txt");

The backslashes are escaped because they are special characters in Java.
 
jQuery in Action, 2nd edition
 
subject: Accessing files in NetBeans
 
Similar Threads
A newbie got stuck !
Java EE 5 Development with NetBeans 6 - external ant script
Importing own Packages
Creating a new file type in NetBeans
Mass Loading of Java Programs into NetBeans