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 to perform binary search in java?
Does a function need a return?
Which is the best approach for creating thread ?
which one the better thread emplemented thread or extended ?
What is the basic of java?
What is jagged array in java?
Is array dynamic in java?
What is meant by final class, methods and variables?
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
I have an HashMap object, which has with key and value pair. It has 10 keys and values in that object. Now the question is I want insert new key and value in middle or any where in that list but not at the end or at the top. Is it possible or not. If yes how can we achieve this one?
Is arraylist ordered in java?
What must a class do to implement an interface in java programming?