list file number

Ads

 
 
 

Share on Google+Share on Google+

sumer
list file number
1 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

April 16, 2009 at 5:40 PM


Hi friend,

Use the following code:

import java.io.*;

public class CreateFile{
public static void main(String[] args) throws IOException{
int countF=0,countD=0;
File f = new File( "C:\\" );
File[] listOfFiles = f.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
String text=listOfFiles[i].getName();
System.out.println(text);
countF++;
}
}
System.out.println("No. of Files : "+countF);
System.out.println();

for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isDirectory()) {
String dir=listOfFiles[i].getName();
countD++;
System.out.println(dir);
}
}

System.out.println("No. of Directories : "+countD);
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
list file number - Java Beginners
list file number  sir you still haven't understand my problem. i have to list out only the number of files in a given directory,your solution still give number of (files+directories) in given directory. are jfilechooser provide
line number in a file of entered string
line number in a file of entered string  when i entered string from console , it should show line number in a file of that string
Advertisements
Java file number of lines
Java file number of lines In this section, you will learn how to count the number of lines from the given file. Description of code: Java has provide... have used counter here to detect the number of lines occurred in the file
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program
java program to insert data into a file and count the number of words from the file???????
java program to insert data into a file and count the number of words from the file???????  java program to insert data into a file and count the number of words from the file
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
writing a text into text file at particular line number
writing a text into text file at particular line number   Hi, thanks for quick response, I want to insert text at some particular line number.. after line number four my text will display in text file using java program  
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.UnsupportedClassVersionError: Bad version number in .class file...java.lang.UnsupportedClassVersionError: Bad version number in .class file  My java servlet not working correctly on my website. I have tried every
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Map words to line number in text file and show occurence
Map words to line number in text file and show occurence  hi i want to Map words to line number in text file and show occurrence of word in java coding
Java file list()
Java file list() This section demonstrates you the use of method list(). You... listFiles() method or by list() method. Here we will discuss the method list() of File.... Then we have called the list( ) method through the File object. This method
Retrieve a list of words from a website and show a word count plus a specified number of most frequently occurring words
Retrieve a list of words from a website and show a word count plus a specified number of most frequently occurring words  I have to: 1.Retrieve...;String,Integer> object where the value is the number of occurrences of the word
How to rectify "Bad version number in .class file" exception in Eclipse
How to rectify "Bad version number in .class file" exception in Eclipse ... this request. exception javax.servlet.ServletException: Bad version number in .class file org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274
JDOM Attribute Example, How to add a list of attribute at a xml file element.
JDOM Attribute Example, How to add a list of attribute to a xml file In this tutorial, we will see how to add a list of attribute to a xml file element... a list of attribute. By using Attrribute class we will create number of 
List
List  i do have one list object, i want to compare this list from database table and if match found i want to update the list
Program to count the number of unique words in a file using HashMap
Program to count the number of unique words in a file using HashMap  ...[]) throws FileNotFoundException { File f = new File("C:/547647/word...()); System.out.println("The number of unique words: "+uniqueValues.size
List
List  getting values from a form and make a list of them and store them into database
Given a list, identify which are requirements for an EJB-jar file.
Given a list, identify which are requirements for an EJB-jar...;   Given a list, identify which are requirements for an EJB-jar file. The ejb-jar file MUST CONTAIN, either
How to make a list from file text in J2ME - Java Beginners
How to make a list from file text in J2ME  I was trying to make a method that read file from text and make a list of it, I have tried ReadHelpText...) { } return null; } kamus.txt file contains: iconSebuah lambang kecil berupa gambar
How to get of lastmodified file list between two times in java?
How to get of lastmodified file list between two times in java?  Hi, here is a code that list the last modified files in a directory between two... times like get the last modified file bet 02:00:00am and 01:00:00am (so
putting words to line number form a java file/test file and show occurrence
putting words to line number form a java file/test file and show occurrence  hi all i want putting words to line number form a java file and show occurrence but i cant use mapping method i can only use the LinkedList
JSP List Size
return the number of elements are added to the list.  Understand with Example... JSP List Size          JSP List Size is used to get the size
linked list
linked list   how to add student and mark and number from file in linked list and print them also how to make search function plz can help me sooon
Java get File List
Java get File List      ... the directory 'C:\\" to the constructor of class File.  file.listFiles...[]){  File file = new File("C:\\");    
Count number of nodes
("\nThe number of nodes in a list are: %d\n",n); } Output... ) { printf("The data in the list are\n"); while (p!= NULL) { printf...; struct node *start = NULL ; printf("Enter number of nodes to be created
number sorting
number sorting  program to sort a list of numbers in descending order...(System.in); System.out.println("Enter List Elements: "); ArrayList<Integer> list=new ArrayList<Integer>(); for(int i=0;i<
Linked List
removeFromFront(); public Object removeFromBack (); public boolen isEmpty(); } The number in the following logical linked list represents Computer Number. 76(head) 98 54...? to ?66?. The segment should also display the new contents of the linked list
Retrieve the dynamic capacity of a list
of a list i.e. retrieving the number of objects contained in it. Here is an example... using add(object) method. Now retrieve the total number of objects contained
Tutorials   
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java

Ads

 
Advertisement null

Ads