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 |
how your day start in your company
What is the difference between this() and super()?
Does set allows null in java?
Why do we declare a class static?
What is the original name of java?
What is final method in java?
What is immutable state?
how to print a numbers from 1 to 100 with out using control structures?
Can java inner class be static?
What is the difference between Object and Instance?
How Marker Interfaces are instruct to complete the desired need ?
What is a 16 bit word?