Results 1 to 6 of 6
Thread: java file handling problem
- 04-05-2012, 11:10 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
java file handling problem
import java.util.*;
import java.io.*;
class Test
{
public static void main(String [] args)
{
File f2=new File("E:\\data.txt");
long b=f2.length();
System.out.println(b+f2.getName()+f2.getPath() +f2.getAbsolutePath()+f2.exists());
boolean a=f2.isFile();
System.out.println(a);
}
}
the length() method returns 0 rather than the actual size . f2.exists() always returns false .. isFile() always returns false ..
Plzzz reply asap
- 04-05-2012, 11:19 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: java file handling problem
I guess the file doesn't exist?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 04-05-2012, 11:21 AM #3
- 04-05-2012, 11:21 AM #4
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Re: java file handling problem
it exists .. the other methods .. return the correct name and path .. but exists() and length() are not working .
- 04-05-2012, 12:52 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: java file handling problem
The paths will shows the correct path, but that does not mean the file exists.
That will print out a path.Java Code:File f = new File("someFIleThatDOesNotExist.txt"); System.out.println(f.getAbsolutePath());
That path represents the path that will be used when the file is actually created.
It does not currently exist.
So, as Jos says, the File does not exist.Please do not ask for code as refusal often offends.
- 04-05-2012, 02:35 PM #6
Similar Threads
-
File handling
By Dayanand in forum New To JavaReplies: 7Last Post: 03-23-2011, 07:31 AM -
Best way to solve this encryption file handling problem.
By SeanC in forum New To JavaReplies: 0Last Post: 12-22-2010, 11:32 PM -
Java/OS File Handling
By Revenna in forum New To JavaReplies: 3Last Post: 05-04-2010, 10:08 AM -
file handling problem
By gcampton in forum EclipseReplies: 19Last Post: 01-05-2010, 01:18 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