Results 1 to 18 of 18
Thread: File handling
- 09-20-2010, 04:39 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
File handling
Hello there,
I'm using NetBeans 6.9.1 in Windows and I wanted to do a simple file handling. First, I wanted to check if a file exists. The file I wanted to open is in UNIX. I've tried the code below. It works if you're looking for a file that's in Windows. It doesn't work if you're looking for a file that's in UNIX.
Thanks in advance :DJava Code:String path = "<path here>"; File f = new File(path); boolean ext = f.exists();
- 09-20-2010, 05:07 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you show me the file path, how did you define it?
- 09-20-2010, 05:07 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-20-2010, 06:02 AM #4
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
- 09-20-2010, 10:59 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Yes, do you get any errors?
Does the user the Java code is running under have permission to view the directory the file is in?
- 09-20-2010, 03:31 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Hope the file exist in the specified path, and again, did you get any error message?
- 09-20-2010, 11:44 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
No, I didn't get any error message. And yes, the file exist in the UNIX directory. I already did the chmod 755 command.
EDIT:
Someone told me here that I have to move my server to a linux box. Will that help?
- 09-21-2010, 08:54 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You mean you're not running this on the same box?
You could have mentioned that.
Where is the code running (what OS)?
- 09-21-2010, 09:14 AM #9
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
Let me clarify a bit,
As of now, I'm using the Tomcat 6.0 that's built-in with NetBeans 6.9.1, which is installed on Windows XP SP3. What my friend told me is that I should have a different server that is running on a Linux box. I think the OS that's available here is Solaris 9 or 10.
My concern now is that, will it help me in my situation by having a different server that's running in a Linux box?
- 09-21-2010, 09:29 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
So you have your code on a Windows box, and you are attempting to access a file on a Unix box?
I just need to clarify what it is you are trying to do.
- 09-21-2010, 09:37 AM #11
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
Yes, that is correct :D
EDIT:
Do you need to input somewhere the hostname, your UNIX username and password?
- 09-21-2010, 09:45 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
This is why.
I asked earlier if the file was visible to the user the Java program was running as...
- 09-21-2010, 09:46 AM #13
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
Were you expecting miracles? I have a couple of laptops and my home directory is /home/jos on all my machines but you can't reach them (I can). Unless you have a Samba server running there is no file system involved so you should reach that file through other means. Authorization is more than likely required. You should've mentioned those 'details' when you started this topic.
kind regards,
Jos
- 09-21-2010, 10:16 AM #14
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
Wow, talk about being kind with the new guys here...
- 09-21-2010, 10:21 AM #15
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Well, it does get frustrating when you ask questions and they aren't answered sufficiently, only to find that a full answer would have helped significantly.
We do have jobs you know...
- 09-21-2010, 10:21 AM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
- 09-21-2010, 10:30 AM #17
Member
- Join Date
- Sep 2010
- Posts
- 7
- Rep Power
- 0
Sorry about that. It's just me that's being new in this kind of field.
I'm giving vague information because I really don't know what to say. Sorry for being a newbie in this field.Kindness has nothing to do with it; if you want us to help you you have to supply all the (relevant) information. Vague indications are not enough and often misleading (as you could've noticed).
- 09-21-2010, 11:49 AM #18
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,373
- Blog Entries
- 7
- Rep Power
- 17
It's OK, you're no exception to the rule; lots of people new to programming and computers panic and give just vague irrelevant indications and they want immediate help. We don't have crystal balls and the field of computer science has nothing to do with magic so only clear information counts, only then are we able to help you. At least describe your computing environment that's giving you trouble ...
kind regards,
Jos
Similar Threads
-
Java/OS File Handling
By Revenna in forum New To JavaReplies: 3Last Post: 05-04-2010, 10:08 AM -
Regarding File Handling
By ravjot28 in forum New To JavaReplies: 1Last Post: 01-20-2010, 09:15 PM -
file handling problem
By gcampton in forum EclipseReplies: 19Last Post: 01-05-2010, 01:18 PM -
handling WAV file
By zellazode in forum New To JavaReplies: 1Last Post: 09-08-2009, 03:46 PM -
Problem in File Handling in Java
By getbiplab in forum New To JavaReplies: 6Last Post: 03-31-2008, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks