Can someone tell me if there's a problem with my recursive file search?

I've been trying to get a recursive file search working. I wanted to go through each directory and add every file to a database so I can use extremely fast, advanced file searches through my program. I wrote up this code
<CODE>
package myrecursive;
import java.io.*;
public class MyRecursive {
public static void main(String[] args) {
recursiveSearch("D:/");
private static void recursiveSearch(String x) {
String tempFile="";
File dir = new File(x);
File[] curDir = dir.listFiles();
for (int a=0;a<curDir.length;a++) {
if (curDir[a].isDirectory()==false) System.out.println(curDir[a]);
else {
tempFile=curDir[a].toString();
recursiveSearch(tempFile);
</CODE>
The code was simple but I didn't think I could write it like this without killing my resources or getting a buffer overload. I ran it and it worked. However, I am running a high end box with 512MB of RAM and a 2.4 GHz processor so I don't know if what worked for me will work on a lower end machine. I was told you should avoid calling a method from itself is this true? How would I avoid it? Should I keep it this way? Any recommendations?
NOTE: I ran the code through JBuilder. JBuilder has a console built into the IDE and will return a noise and the error code whenever it hits an error. Although my app kept shooting out files it found out I heard a noise a few times. Does this mean anything?

First the formatting tags should be "[ ]" not "< >".
I was told you should avoid calling a method from itself is this true?Recursion is a valid programming technique and in fact makes many algorithms much easier to code.
so I don't know if what worked for me will work on a lower end machineIt may be a little slower but it will still work. Recursion only causes a problem with resources when you have many levels of recursion. On my system I have:
C:\WINDOWS\TEMP\Temporary Internet Files\Content.IE5\
In this case there is only 4 levels of recursion. This is not going to cause a problem. You would generally only have problems if your recusion routine is not working correctly and you get in an infinite loop which will lead to resource problems and an abend.
In your particular case you aren't even using many resources at all since all you are doing is printing the file name.
This [url http://forum.java.sun.com/thread.jsp?forum=57&thread=435487&start=3&range=1]post shows a recursive routine that list all files for a directory and displays them in a table. In this cause you might have a problem with resources depending on the number of files in the directory. But the resource problem is because of the memory to hold the filenames in the table, not because a recursive routine was used to get the filename.

Similar Messages

  • After updating my ipad to 6.0.1, it will no longer connect to personal hotspots on any make of phone. Can someone tell me if it is a problem with the software?

    Is anybody have the same problem as mentioned above?

    First the formatting tags should be "[ ]" not "< >".
    I was told you should avoid calling a method from itself is this true?Recursion is a valid programming technique and in fact makes many algorithms much easier to code.
    so I don't know if what worked for me will work on a lower end machineIt may be a little slower but it will still work. Recursion only causes a problem with resources when you have many levels of recursion. On my system I have:
    C:\WINDOWS\TEMP\Temporary Internet Files\Content.IE5\
    In this case there is only 4 levels of recursion. This is not going to cause a problem. You would generally only have problems if your recusion routine is not working correctly and you get in an infinite loop which will lead to resource problems and an abend.
    In your particular case you aren't even using many resources at all since all you are doing is printing the file name.
    This [url http://forum.java.sun.com/thread.jsp?forum=57&thread=435487&start=3&range=1]post shows a recursive routine that list all files for a directory and displays them in a table. In this cause you might have a problem with resources depending on the number of files in the directory. But the resource problem is because of the memory to hold the filenames in the table, not because a recursive routine was used to get the filename.

  • My new iPhone4S could not start after the Apple mark disappear, the running screen stand still over 30mn. Can someone tell me how to solve this problem.

    My new iPhone4S could not start after the Apple mark disappear, the running screen stand still over 30mn. Can someone tell me how to solve this problem.
    I tried to connect to iTune hoped to restore the system but iTunes did not reconige it.

    here is link to the apple product feedback website:
    http://www.apple.com/feedback/

  • Can someone tell me how to create accounting entries with the account status as error

    Hi,
    Can someone tell me how to create accounting entries with the
    account status as error?
    Thanks!!
    Danny

    It's call fixed/static background, and it is NOT directly support by iweb, you will need post processing either in html or javascript.
    Varkgirl (you need to search the previous forum) and I did it since iweb1:
    try Safari, and scroll: http://www.geocities.com/[email protected]/Links.html
    invisible link? roddy, fishing for info again?

  • Can someone tell me the best stylus to use with good note app.

    Can someone tell me the best stylus to use with good note app?

    I use the Jot Script stylus with Good Notes on a daily basis, and I'm realy satisfied. I recently did some videos to show how this works for me, you could check it out, and I hope it'll help you find the perfect stylus and app!
    https://www.youtube.com/user/AurelienChe

  • Can someone tell me how to buy an app with an iTunes gift card.  Is it possible to do it?

    Can someone tell me how to buy an app with an iTunes gift card.  Is it possible to do it?

    redeem the gift card first (bottom of itunes store on ur ios device). then purchase content.

  • I can not do the update , what should I do to fix this error ? "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanks

    I can not do the update , what should I do to fix this error ?
    "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanks

    Hi,
    Please refer to the help document below:
    Error downloading, installing, or updating Creative Cloud applications
    Regards,
    Sheena

  • For the last 2 days whenever I try to upload photos from my iPhoto page to facebook I get an error message: Bad Image There was a problem with the image file.  I haven't knowingly changed any settings on iPhoto or facebook. Can anyone help, please ?

    I need help with uploading photos from iPhoto to facebook. I could do it till 2 days ago. Now any new photo I try to upload gives me an error message:
    Bad Image
    There was a problem with the image file. 
    Please help.

    Can you drag it to the Desktop?

  • [SkyDrive] Files can't be uploaded because there's a problem with a file or folder.

    On Windows 8.1 RTM, the SkyDrive metro client shows a message that "Files can't be uploaded because there's a problem with a file or folder." and lists one particular file. When I installed the PC, I have switched then Access all files offline
    option to On.
    The file resides in a directory I have deleted from the disk. When attempting to get rid of this "problem" (as there are no hints nor UI available) I have manually checked that the directory does not exists on the disk any more, as well as deleting
    the directory from cloud storage using a web browser. However, the message is still there.
    Restarting the computer several times nor keeping it idle for a significant amount of time did not help.
    How to get rid of that "problem" / how to fix it?

    Hi
    Let’s try to redirect the skydrive folder and sync again to see what’s going on:
    1. Open regedit and find following key:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\SkyDrive
    2. Change “UserFolder” to another location.
    3. Open the SkyDrive Metro app to confirm your files and new directory.
    Then check the issue again. 
    Regards,
    Kate Li
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • TS1559 my wifi is grayed out... No one can fixed it...there is a problem with hardware. IC problem inside the phone. Apple have any facility like service after sales etc. Multi billion company but no priority for customers ?

    my wifi is grayed out... No one can fixed it...there is a problem with hardware. IC problem inside the phone. Apple have any facility like service after sales etc. Multi billion company but no priority for customers ? Just try to look at google search you can find lot of people who have same problem with iphone 4s. It is surly manufacturing default. Is that apple reputation lounching New virsion Iphone with diffective hardware.

    Plz dont give me idea setting>reset>reset network configration .... I already did it..... give me proper solution... who can replace default hardware from my iphone?????????????????????

  • Printing Error: There is a problem with a font file.

    I get this error when I try to print:
    "Printing Error: There is a problem with a font file."
    I tried exporting to PDF and printing from there. I get this message:
    "An error exist on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem."
    Has anyone encountered this problem?

    You may have a corrupted font. Try substituting fonts to see which one is the problem.

  • Can someone tell which player I should use to run flv,avi file in my iPad 3 after download from any site ????

    Can someone tell me which player I should use to run flv,avi file in my iPad 3 after downloading video from any site ????

    Can someone tell me which player I should use to run flv,avi file in my iPad 3 after downloading video from any site ????

  • Please can someone tell me how to get yahoo chat with sound on mac.os x

    new to mac.3 days and counting.i cannot seem to get installed yahoo chat with sound installed on my new macbook pro?I've installed all the steps,messenger with sound,windows media stix,stuffit expander,flip4macWMV.mpkg,yahoo messenger 2.5.3(osx) i am also unable to run any windows media player (videos) Can someone please help????

    Yahoo Messenger for Mac does not have audio capability, only video and text.

  • Satellite Pro L20 -can anyone tell me whether I have a problem with screen?

    Hi,
    I have a Pro L20 - PSL25E and i have recently been having problems with the screen, it has been intermittently flickering/losing colour and almost whiting out (when the colour fades white vertical lines start to appear).
    This seemed to become worse after i dropped it (only from about 2 feet off the ground not a big drop).
    I thought the sceen may be going, but the perfomance of the laptop seems to be affected when this is happening, the laptop has started to run very slow (the mouse tracks slow, programs I've clicked take ages to run and it sometimes freezes until it stops flickering) which had me thinking it might be a virus or perfomance issue.
    My screen drivers are up to date, i ran a full scan with McAfee, ran a system clear-up and a defrag.
    I was wondering if anyone knew whether this seemed like a problem with the screen connections and would need replacing or whether it could be repaired, or whether it was a perfomance issue?
    Any help would be much appreciate thanks!
    Rebecca.

    Sounds like the Graphics chip has a problem, which I think is a Mainboard replacement.
    You can get a quote for the repair at an Authorized Service Provider. There is an ASP list on the Toshiba website.

  • Hi can anyone tell me if they have had problems with FaceTime on ipad? It works on my iphone but not ipad?

    Hi there
    Can anyone help me resolve the problem with face time? Only started within last month, I can FaceTime using iphone but not ipad.
    It says connect and then does not connect and say unavailible?

    Apple has released a document which is reported to address the recent FaceTime issue.
    http://support.apple.com/kb/TS5419

Maybe you are looking for