File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File object creation

 
mahesh deshpande
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vegad Arvind
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic