Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » File HandlingRSS Feeds

File handling program to display directory contents

Posted By: Easy Tutor     Category: Java     Views: 5943

Write file handling program to display directory contents contains file or directory.

Code for File handling program to display directory contents in Java

import java.io.File;

class  DirList
{
    publicstaticvoid main(String[] args) 
    {
         String dirname= "e:/songs";
         File f1 = new File(dirname);
         
    if (f1.isDirectory())
    {
              System.out.println("Directory of " + dirname);
              String s[] = f1.list();

              for (int i=0;i<s.length ;i++ )
              {
                    File f = new File(dirname + "/"+ s[i]);
                    if (f.isFile()){
                         System.out.println(s[i] + " is a File");
                    }
                    else{
                        System.out.println(s[i] + " is a directory");
                    }
              }
     }
    else
    {
           System.out.println(dirname + " is not  a directory");
    }
    }
}
  
Share: 


Didn't find what you were looking for? Find more on File handling program to display directory contents Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of File handling program to display directory contents is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Mike Juma from Kenya Comment on: Mar 24
THANK-YOU in advance for you kindness and help on this question.


Display Input-Output from database to device, phone and input new data


OnlineClass
IdNumber First LastName Course City DateEnrolled


2101 Rajesh Khan PHP London 05/03/2012
2102 Mohamed Sarwar vbnet Mahwah 06/03/2011
2103 Hamisi Juma Csharp Mombasa 08/03/2010
2104 Erik Dell cplusplus JeseyCity 09/03/2009
2105 David Maina php Nairobi 10/03/2008
2106 Mahesh Shah java NewDelhi 05/03/2007
2107 John Stevens mysql Dearborn 05/03/2006
2108 Anthony Rwandiga sql Kigali 07/03/2005


How can I write a code in Java using above input from access or sql and display that information on a phone? Update student information to the database via hand held device and phone.

1. For example when I enter student id on the phone it displays the rest of the information (name, course) as it interacts with the database.

2. I would like if I scan a student ID using a hand held device it gives me the name course etc., while being at the same time being able to input and update new student information to the database through handheld device or phone. Prosperity and peace to you.

AGAIN THANK-YOU FOR YOUR KIND ASSITANCE AND INSIGHT.

PEACE AND PROSPERITY TO YOU.

View All Comments