Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners list file number

Have Programming Question? Ask it here!
 
 
 


sumer
list file number
1 Answer(s)      5 years and a month ago
Posted in : Java Beginners



Advertisement
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


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
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
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
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
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
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
List
List  getting values from a form and make a list of them and store them into database
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
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
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
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
Java get File List
Java get File List      ... the directory 'C:\\" to the constructor of class File.  file.listFiles...[]){  File file = new File("C:\\");    
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
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<
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code   //here my file nameis sample.xls and this file contain some blanks cells how to read and how
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
List interface
List interface  What is the List interface
linked list
number of students register each semester. You are required to write a Java program to manage the registration details for the institute. 1. Use a linked list to manage the details of all registered students. a. Create your own linked list
Count number of "*"
Count number of "*"  I have this code to count the number of * from a string entered. but I need to find it from an text file. Any idea? import...++; } } System.out.println("The number of vowels in the given sentence
linked list
linked list  program for single linked list
list boxs
list boxs  i have two list boxes first list box values from database and i want to assign selected options to the second list box using jsp is it possible to do this in jsp
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
List interface
List interface  Give me some of the real time examples that can be developed based on List and its implemented classes
buzz number
buzz number  buzz number
PHP SQL Number of Rows
PHP SQL Number of Rows      .... To understand how to count the number of rows in a table, we have created a sql_num_rows.php file. If you are not connected to the database, then create a connection
Java list
Java list  What is the difference between a Choice and a List
List of mobiles
List of mobiles  which mobile phones support j2me
prime number
prime number  get one number and check the number prime or not using if statement   Java Check Prime Number
List In Java
gives the number of available elements in the list. Syntax : int size...List In Java In this section we will read about the List data structure in Java and how the List data structure can be implemented in Java. List data
the number of parameters
the number of parameters  How do I find out the number of parameters passed into function
Number in array
Number in array  How to write a program to check the number that we are entered from keyboard is in the given array
prime number
prime number  check prime number using if statement   Java Check Prime Number
prime number
prime number  check prime number using if statement   Java Check Prime Number
linked list
linked list  Hi i have a problem with linked list ! how and where i can use linked list? please give me some example.   Please visit...://www.roseindia.net/java/beginners/linked-list-demo.shtml
 

 

 

DMCA.com