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);
}
}

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we start a thread twice in java?

508


Explain the difference between collection api and stream api in java8?

509


What is singleton service?

508


Explain an algorithm to find depth of a binary tree.

548


Is main is a keyword?

579






What is boolean example?

525


Difference between default and protected access specifiers?

504


What is number data type in java?

553


Why does java have two ways to create child threads?

464


How do you replace a string in java?

543


Which variables are stored in heap?

541


Can we define static methods inside interface?

523


What is finalize()?

608


what are different ways in which a thread can enter the waiting state? : Java thread

492


Name some OOPS Concepts in Java?

639