wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes File object creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "File object creation " Watch "File object creation " New topic
Author

File object creation

mahesh deshpande
Greenhorn

Joined: Oct 26, 2000
Posts: 19

Hello friends
I tried to construct file object specifying path for a file on the local disk as well as using a file on the floppy drive as follows. It gives problem when I construct new File with path of the file on floppy disk.
File f1 = new File( " c:\\jdk1.3\\bin\\test);
it compiles & gives result for all File class methods like exists(), canWrite(), canRead() etc.
but when i do
File f2 = new File ( " A:\\javaranchquestion "); // this file is there on my floppy drive.
it compiles but returns false for exists(), canRead(), canWrite() methods
My question is
Is it that the File object will be created only with "path" pointing to the existing file on the local drive?
Hari Gangadharan
Ranch Hand

Joined: Mar 08, 2001
Posts: 73
Try using a smaller file like a:\\test and post your experience. I am sure drive does not matter. You can read and write to any file to which you have access. I am guessing that there may be some issue with the handling of long file names for floppy disk.
Keep us posted
-- Hari Gangadharan


<B>Hari Gangadharan</B><BR>Unix is user friendly..<BR>but it chooses to whom it is friendly with!
Vegad Arvind
Ranch Hand

Joined: Jan 10, 2001
Posts: 42
Hi,
i tried
File f2 = new File ( " A:\\javaranchquestion.txt"); // this file is there on my floppy drive.
it compiles and returns true for exists(), canRead(), canWrite() methods
I think it doesn't matter whether file/dir is in hard drive or floppy drive.
Avi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File object creation
 
Similar Threads
Directory not writable
how to determine whether removable media is present
determining whether directory is available
Ensuring that a file is not currently being written to
Properties File?