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 are the benefits of operations in java?
what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading?
What is inheritance?
5 Answers Accenture, Hexaware, Syntel,
What is difference between path and classpath?
What methodology can be utilized to link to a database?
What are the methods to rectify ambiguities in the interfaces in JAVA?
What is java oops?
what is singlton class?where it is use in real time senario.
How do you add an element to a set in java?
What is the arguement of main method?
How will you invoke any external process in java?
What is hashset in java?