import java.io.*;
class Demo
{
public static void main(String args[])
{
File f=new File("1234.msg");
String arr[]=f.list();
System.out.println(arr.length);
}
}
Answers were Sorted based on User's Feedback
Answer / sarath
so what is your question..?
the code gives compilation error... because it should throw a IOException..
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / meziane
The list() of the class java.io.File "returns an array of Strings naming the files and directories in the directory denoted by this abstract pathname."
http://docs.oracle.com/javase/6/docs/api/java/io/File.html#list%28%29
The abstract pathname is the path specified in File f = new File(patAsString).
The method returns null, if the abstract pathname does not denote a directory (i.e an existing directory).
No compilation error.
Is This Answer Correct ? | 0 Yes | 0 No |
What is application system?
Name component subclasses that support painting in java programming?
How do you start a thread?
What are the advantages of arraylist over arrays?
I have one Shopping cart application, i that i have selected some items, while clicking submit button by mistake i have clicked twice or trice, that time items are selected twice or trice. Actually i want only one copy of items but its selected twice or trice. So how can we avoid this problem?
Explain java coding standards for methods?
What are generic methods?
Where is const variable stored?
Can we use string in the switch case?
How many digits is int32?
Which collection does not allow duplicates in java?
Explain a few methods of overloading best practices in java?