| | |
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 |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle output print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows





