File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing files in NetBeans

 
Jack Mullaly
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Jack Mullaly
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic