| | |
It Prints nothing from the ArrayList?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 37
Reputation:
Solved Threads: 0
would some one be kind enough to copy and paste and compile this code, I get no results to the terminal, my criteria should bring a few results
it compiles, if you comment out the big if statement, then lots of results come to the terminal window
I hope know one is getting annoyed by me!
Java Syntax (Toggle Plain Text)
import java.io.*; import java.util.*; public class MainFourA { public static void main(String[] args) { File[] filesOnComputer = File.listRoots(); ArrayList listOfFiles = new ArrayList(); System.out.println (filesOnComputer.length); for(int index = 0; index < filesOnComputer.length; index++) { listOfFiles.add((File)filesOnComputer[index]); if(filesOnComputer[index].isDirectory()) { System.out.println ("here we are-"+filesOnComputer[index].getPath()); search((File)listOfFiles.get(index)); } else System.out.println ("This is not the directory-"+filesOnComputer[index].getPath()); } } public static void search(File f) { try { ArrayList<File> arrayList = new ArrayList<File>(); ArrayList<File> arrayListAgain = new ArrayList<File>(); File[] files= f.listFiles(); for(int index = 0; index < files.length; index++) if (files[index].isDirectory()) { search(files[index]); } else if (files[index].isFile()) { System.out.println ("here we are---" + files[index].getName()); arrayList.add(files[index]); arrayListAgain.add(files[index]); if (arrayList.get(index).length() == arrayListAgain.get(index).length() && arrayList.get(index).hashCode() != arrayListAgain.get(index).hashCode()) { System.out.println (arrayList.get(index).getName() + ", " + arrayList.get(index).length() + " bytes."); } } System.out.println (f.getName()); } catch (Exception e) { } } }
it compiles, if you comment out the big if statement, then lots of results come to the terminal window
I hope know one is getting annoyed by me!
Last edited by caps_lock; May 25th, 2009 at 11:32 am.
![]() |
Similar Threads
- Java Arraylist Help Please (Java)
- WritetoDisk method using ArrayList (Java)
- Using operator[] with an ArrayList (Java)
- factorizing numbers (Java)
- Storing Point2D.Double objects in an ArrayList. (Java)
- Java Programmers wanted. Need Help please (Java)
- Need Help with ArrayList sorting (Java)
- Linked arraylist (Java)
Other Threads in the Java Forum
- Previous Thread: Urgent Help!
- Next Thread: Switch Case
| Thread Tools | Search this Thread |
android api applet application array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads time tree unlimited utility webservices windows





