Results 1 to 3 of 3
Thread: :( Text File Opening Problem
- 06-01-2011, 09:32 PM #1
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
:( Text File Opening Problem
I am just got trapped in a very bad situation,
Trying to open a text file and shows the text into a jTextPane... But problem is that when i am trying to open that file with a File object it gives an error of path not found,
I had tried two ways to open it :
1)
here the dicrectory "FileFolder" is different from the folder in which the Class is created (whose name is "Classes"), but both the folders are in same Source folder "src" in my NetBeans Project Folder.Java Code:File f = new File("/FileFolder/file.txt");
It shows me error that Specified path is not found
2)
The second way i am trying is :
I have tried this way by copy the file.txt into that same folder in which my class is exist that is, Classes folder..Java Code:File f = new File(getClass().getResource("file.txt").getFile());
But her also a strange error occurs and message shows that :
The system cannot find the path specified.
Actualy it tries to open the path :
C:/.../NetBeansProjects/MyProject/build/classes/Classes/file.txt
I know this is wrong, but i am unable to understand that WHY IT OPENS THE "CLASSES" FOLDER TWO TIMES????
Actually that correct path must be like:
C:/.../NetBeansProjects/MyProject/build/Classes/file.txt
Please help me out from this........
Thanks
- 06-02-2011, 02:14 PM #2
What happens if you take the program outside of the IDE and try to execute it in a command prompt window?
- 06-02-2011, 03:41 PM #3
Similar Threads
-
age old problem - best way to check if file is text
By madroadbiker in forum Advanced JavaReplies: 11Last Post: 05-27-2011, 06:57 PM -
writing to text file problem
By blumdiggity in forum NetworkingReplies: 1Last Post: 02-26-2010, 02:43 PM -
Focus on Text at the opening of shell
By antogrim2 in forum SWT / JFaceReplies: 0Last Post: 10-14-2009, 10:09 PM -
Opening Text Files with Default System Editor
By Pesch in forum Advanced JavaReplies: 5Last Post: 10-08-2008, 06:17 PM -
Problem in opening a file
By Raghav kv in forum New To JavaReplies: 1Last Post: 08-11-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks