Question:

Scjp 1.5?Java IO problem!!?

by  |  earlier

0 LIKES UnLike

//I am getting an error i can't understand the reason for it!I created a srch //named folder and added few text files into it and i wanted to traverse //them.Can you help me out??

import java.io.*;

class IOSearch{

public static void main(String[]ar)

{

String [] f=new String[10000];

File Srch=new File("Srch");

f=srch.list();

for(String fn:f)

System.out.println("Found" + fn);}}

 Tags:

   Report

1 ANSWERS


  1. Buddy , Java is case sensitive , so the variable Srch is NOT like srch

    Here is ur code corrected

    import java.io.*;

    class IOSearch{

    public static void main(String[]ar)

    {

    String [] f=new String[10000];

    File srch=new File("c:\\x"); // Assume we r looking ino directory x in //drive c :

    f=srch.list();

    for(String fn:f)

               if( fn != null ) System.out.println("Found" + fn);

            

            

            }

                

    }

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.