X-Received: by 10.224.18.132 with SMTP id w4mr10270917qaa.1.1364897513892; Tue, 02 Apr 2013 03:11:53 -0700 (PDT) X-Received: by 10.50.135.10 with SMTP id po10mr1555226igb.4.1364897513835; Tue, 02 Apr 2013 03:11:53 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!t2no30060858qal.0!news-out.google.com!v17ni6816qad.0!nntp.google.com!ca1no20646014qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Tue, 2 Apr 2013 03:11:53 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=182.64.117.233; posting-account=6SonuQoAAACzSakS5dCECcJQe6ylLrzY NNTP-Posting-Host: 182.64.117.233 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Inserting In a List From: subhabangalore@gmail.com Injection-Date: Tue, 02 Apr 2013 10:11:53 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:23175 Dear Group, I am taking out the files in my desktop folder, as, File folder = new File("C:\\Users\\subhabrata\\Desktop"); Next, I am trying to take them out one by one as using for loop and name of each file is converted to String, for( File name :folder.listFiles()){ String s1=name.toString(); System.out.println("####"+s1); System.out.print( name ); } Till this there is no issue, now I am trying to insert name of all the files in an array, generally it can be done, as, ArrayList myList = new ArrayList(); myList.add(s1); But the problem I am facing is, if I put it as, for( File name :folder.listFiles()){ String s1=name.toString(); System.out.println("####"+s1); System.out.print( name ); ArrayList myList = new ArrayList(); myList.add(s1); } I am getting name of files individually but I want to see them as the whole bunch like, myList=["string1","string2","string3",...."StringN"] My aim is to check the names then in another for loop and if match is not found with some defined name update the list. I am slightly new in Java so if anyone can kindly suggest how I should address it. Regards, Subhabrata.