Finding a file

I'm trying to locate a general a file on my machine, only knowing its name. Right now I have the code
public static void visitAllDirsAndFiles(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
visitAllDirsAndFiles(new File(dir, children));
System.out.println (children[i]);
And that works perfectly fine for finding out whether the file exists, since it lists everything under the c drive. The problem is, once I change String[] children = dir.list();
to
File [] children = dir.listFiles(); and children[i] to children[i].getPath();
the program no long compiles. WHY IS this?! I want to find the pathname of the file i'm searching for.
All advice would be appreciated!

OK Here's a Followup question:
Right now, I want to unzip a file. Assume I've already created the unzipping method:
unzipFile (File file_input,)
When I call the unzip method like this:
File f = new File ("Java Notes.zip");
unzipFile (new File (" " + f.getAbsolutePath());
Nothing happens!
but when I call it like this:
unzipFile (new File ("C:\Documents and Settings\Java Notes.zip"));
it unzips properly!
I assume its because when I get the AbsolutePath, it returns the path with the separator ' / ' instead of ' \ '.
So I'm wondering if there's anyway to convert between the two types of separators. THANKS!

Similar Messages

  • Help:Can not find the file in jar!

    Hello everyone:
    I build a project using Netbeans 5.0 and make a jar file with it...
    The code in the project as follows will throw an exception described that it can not find the file named datasource-config.xml
    String dataFilePath = getClass().getResource(dataFile).getPath();
    //System.out.println("filepath:"+dataFilePath);
    InputStream input = new FileInputStream(dataFilePath);
    when I run the project with the main() function as an entry it works perfectly and output:
    filepath:/C:/projects/java_project/search/build/classes/com/cn/wxjt/lucene/config/datasource-config.xml
    But when I compressed the project with jar and run it , it will show:
    filepath:file:/C:/projects/java_project/search/dist/search.jar!/com/cn/wxjt/lucene/config/datasource-config.xml
    there is a (!) between search.jar and /com/cn/wxjt...
    I dont know why I generate a ! symbol in the file path... Is it cause the exception->
    java.io.FileNotFoundException: file:\C:\projects\java_project\search\dist\search.jar!\com\cn\wxjt\lucene\config\datasource-config.xml
    If you have any idea, plz tell me.
    Thank you and best wishes to you !
    :)

    If the file you want to read is in your jar file, use
    getClass ().getResourceAsStream
    (relative_path_file_name)Hope that help,
    Jackhey jack i want to open the file as new File
    i m using this.getClass().getResource("resource/backend.xml");
    the resource is the directory inside the jar file.
    when i prints the url it shows:
    the jar file is in the WORK directory
    URL : jar:file:/home/neeraj/WORK/show.jar!/resource/backend.xml
    now when i creates new File using the url.getFile() method the file does not exist.
    although the same programs runs well when i uses the InputStream
    so plz tell me cant I create a new File from the above method????
    thanks in advance
    with regards
    neeraj

  • Move all my music to another folder but Itunes can't find the files!

    I have all my music on my desktop in small folders for each artist.
    But now i don't have room anymore, because i have to much music.
    So i want to move it all in to a folder called "Music". But when i do that
    Itunes can't find the files, and i have to search for each file, to find the new location instead of the desktop. How do i move my music more easily? So i don't have to synchronize it all in again, with the right album covers and that..
    Please, need some help here!

    You need to open your preferences file in iTunes and click on advance then select the location of where you put the folder.  http://support.apple.com/kb/HT4527

  • I have updated my iphone software from ios4.1 to 5.0.1(9A405) through itunes and i want to find the file which i download but i can`t find it in itunes where can i find it

    I have updated my iphone softwarefrom ios4.1 to 5.0.1(9A405) and i want to jailbreak my iphone to download cydiaafter i do that i download programe named sn0wbreeze2.8b11 but when i startedto jailbrake the programe ask me to drag&drop or browse for ipsw while ialready downloaded but through itunes i try to search on itunes store to get itand drag on this programe but i didn`t found it so, Kindly please tell me howcan i find this file to continue jailbreak my iphone if u have an answer to myproblem please e-mail me at *****[email protected]  or just reply in zis discussion

    See this
    If you can't update or restore your iOS device

  • HT3986 I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation dis

    I've had MS Office:mac 2011 on my imac for around 18 months now.  Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it.  I've just done this using the installation disc which, then said the installation had been successful.
    Outlook is still not working.  Can anyone please advise me on what to do next.

    Remove MS Office 2011 completely (here are instructions) and reinstall it.
    It's not a simple or fast process but it is important to follow all of the steps in order to get all the files that Office scatters around. This will not affect your data files, only MS Office and its preferences.

  • How Do I use TM to find a file on my computers Idisk from today's backup?

    Where do I find the file that is on my Idisk's Time Machine Backup that was on my laptop this morning when TM backed up????? My Idisk had a problem this morning and when I sought help, they had me hit the stop and restart the syncing. The problem is that even though there was a file on my Idisk on my computer from last night, the Idisk syncing reset every file from the mobileme cloud to my laptop and the file on my mobileme cloud was from 2 days ago. Not the updated one from last night. I teach and my attendance is all taken and stored on the Idisk (and synced) from all my classes. Wed & Thursday attendances were on my laptop correctly. (I know because I checked BEFORE they told me to restart the sync button on preferences. My laptop did its normal BU this morning so I am trying to find the excel attendance file on the backup. Can anyone help????????
    I don't know why that happened but it did!!!
    Thanks for any help you can provide.
    Skip

    Dear Thomas,
    I entered TM and found the sparsebundle under the Filesync library. However, it appears NOT to be recoverable and I tried double clicking on it but it doesnt do anything other than show a summary of what it is.
    By the way, I really do appreciate your comments and agree completely. Something strange happened with my syncing of Idisk (which is set to "automatic"). It has been working fine for years. But for some reason, it stopped two days ago and did not let me know. When I tried to put something manually on it (through drag/drop), it never showed up on the Idisk on the cloud which made me notice and check it out by going to Mobileme through the browser. I then went to the tech service for Idisk and they explained that something probably got corrupted so just hit STOP syncing and then hit Automatic again. Which is what I did. Then everything from the cloud went to my Idisk on my computer and for some reason, the latest version of my excel spread sheet for attendance showed two days ago, not last night. so I lost wed/thursday classes. I KNOW it was on my Laptop which is backed up to TM every morning.. Thats why I believe that the latest file IS on my TM backup for this morning. But I can't get to it. Any other help would be appreciated.
    Skip

  • Can't find imovie file on my hard drive

    I have a imovie file on my hard drive that I can't find. I really want to delete it so
    that I can free up some room on my hard rive. It's at least 15 gigs big. I tried using the search icon in the upper right hand corner and I tried using the 'find' option under the 'finder' menu, searching for any files over 5 gigs in size. Can anyone help me find this file so I can get rid of it?
    [email protected]

    An iMovie project is a package, not a file; the actual files inside it are smaller. Use a tool such as WhatSize to locate it.
    (23171)

  • I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    I have problem with Itunes losing where podcasts and some purchased music is located. Don't know how Itunes losing the locations of the files and I can't find the files on my hard drive. What can I do to stop Itunes losing location and restore my files?

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    If your Mac is new-ish and has one of the Lions as its OS, the drives, cards, USB sticks no longer show up, even though they're there. Go to Finder's Preferences and tick the corresponding items in the General and Sidebar tabs.

  • My hard disk suddenly filled up and I can't find the files

    that are causing my hard disk to fill up. I was watching some videos that was on an external drive on my computer using vlc. I finished one movie (.avi file) and then tried to watch the second one in the series. However, the vlc application would not open it. I tried several times. I gave up and tried opening it with the quicktime player. Even though it opened, I got a message that my startup disk was full. That was strange because I am sure I had about 20GB as I was keeping a close eye on my hard disk capacity. I had recently deleted many video files and so I had a rough idea of how much hard disk I should have.
    Anyway, I deleted some movie files to make space and then I checked my hard disk with Disk Inventory X.
    When I did that, I found some strange files.
    There are some temp files some of which are 1GB. The path is private/var/vm/tmp. One file is labeled a Quick Time player launcher document.
    Another one is called "sleepimage". Format is HFS+. It is 4GB. It was modified recently (yesterday). Its path is private/var/vm/sleepimage.
    I don't want to delete anything important by accident.
    I just think this is strange and want to find these files but when I click "Open", it says I don't have permission and I have to locate them in Finder. However, when I type "sleepimage" in Finder, nothing comes up.
    I really want to get rid of any files that take up a lot of space on my computer and that shouldn't be there. Do you think this is some kind of virus? And that's why my computer is filling up with some strange files. There are also many swapfile documents that are 1GB in size.

    I think the problem is Quick Time Player. I am using OS 10.6.8 by the way.
    I tried it out again.
    I had about 26 GB of space before I played an .avi video.
    After the movie started to play (it was slow to load), I got a warning message that my startup disk was full. I opened Disk Utility and it told me I had no space left (about 20 MB or something like that was left).
    I watched to the end of the movie.
    Then I quit Quicktime Player.
    And I shut down the computer.
    I turned on the computer and checked Disk Utility. I have about 26 GB of space.
    I think for some reason Quicktime Player uses up a lot of the disk space when it runs movies that are problematic. This movie I was watching did not open with vlc.
    I normally use vlc to watch movies.
    Probably it doesn't use up this much space when the movie is OK.
    I think there's a problem with this particular movie. It is about 50 MB so it's not that big a file. I watch .smi subtitles with it. The Quicktime Player automatically loads the subtitle file in this case because the subtitle file has the same name as the movie file.
    I watched about 10 movie files from the same series that I downloaded together and did not have any problem watching them. I watched them on vlc. But this latest movie had problems I think (as I repeat). It did not load on vlc even though I waited for a minute, and normally movies load instantly on vlc. 
    So I think that movie file caused problems. It made QT player use up a lot of hard disk space.
    I had better avoid watching that movie in the future. I don't want it to wreck my hard drive.
    So to sum up, everything is back to normal. I have the hard disk space that I should have. However, I am scared of damaging my hard drive due to shonky movie files that eat up all the space when they are played using QT player, and so I will not watch those files in the future, as I do not know why the files do that.

  • I cant access firefox, everytime i try i get that windows can't find the file, i tried redownloading it but it still gave me the same message?

    i cant access firefox, everytime i try i get that windows can't find the file, i tried downloading it again but it still gave me the same message. the problem has nothign to do with my internet because it wonks on internet explorer and everythign is fine, my computer just can't access firefox for some reason. i tried uninstallign ti adn then installing it again, but that didnt work, i tried installing a different version and it still didnt work.
    okay the exact message is" Windows cannot find 'C:\Program Files\Mozilla Forefox 4.0 Beta 1\firefox.exe'. make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search.
    Nothing happens after i install is the "Launch Firefox now" checkbox set, the same message comes up.
    i usually start firefox from the shortcut i have on my desktop but when this happened i thought that the shortcut is the problem, but i went to the Mozilla firefox folder and tried it from there, but it didnt work. i also tried downloading different versions of firefox but that didnt work either.

    can you tell me the solution to "windows cant find firefox" error. thanks.

  • Had to uninstall Firefox, now I can't reinstall. Get error message "Can not find archive file." Please help!

    I believe I had some kind of virus attack. I got everything cleaned up. (I HOPE) In the process of cleaning the virus, I unintalled Firefox because it wouldn't open. Kept getting the error message that Firefox was already open and I had to close out of the sessions or restart the computer. After restarting the computer several times and not being able to find any open sessions in task manager, I uninstalled. When trying to reinstall, I get the error message "can not find archive file." I've tried downloading Firefox from cnet as well as the Mozilla site to no avail. Please help. I'm getting tired of using Chrome already!

    Hello,
    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • Error message on my development workstation: The system cannot find the file specified.

    Post Author: cseverin
    CA Forum: Crystal Reports
    Hi,
    I am currently developing an ASP.NET website using Visual Studio.NET 2005. I am using the .NET 2.0 framework, VB.NET as my programming language and I connect successfully to a SQL Server 2005 database.  I can select, insert, update and delete data from the database elsewhere in my project, so I know basic connectivity isn't an issue.  The problem seems to be with Crystal Reports. 
    I created a folder called 'Reports' in my project and added a Crystal Report file (OpenFiles.rpt) to it.  I designed the report and initally used a hard-coded SQL query as its datasource so I could quickly get the database fields onto the report and preview them.  All worked fine. 
    To make the report accessible to the rest of the website, I created an .xsd dataset file containing the three tables (and their corresponding tableadapters) that the report requires and then redeveloped the report using the dataset as the datasource for the report.  After doing this, the preview no longer worked.
    Next, I added a page to the website and dragged a Crystal Report Viewer Control onto it.  In the code behind the page I wrote:
    Option Strict On
    Imports System.Data
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Partial Class Reports
         Inherits System.Web.UI.Page
         Private objOpenFilesreport As OpenFilesReport
         Private rptOpenFiles As ReportDocument
         Private strLastErrorMessage As String = Nothing
         Private errLastException As Exception = Nothing
         Dim strFileKey As String
         Dim strJurisdictionCode As String
         Dim strStaffId As String
         Dim strReportId As String
         Private Sub ConfigureCrystalReports()
              Dim reportPath As String = Server.MapPath("OpenFiles.rpt")
              Dim rptopenfiles As New ReportDocument
              rptOpenFiles.Load(reportPath)  <== I checked this during execution and the value correctly points to the OpenFiles.rpt file in the Reports     folder of my project
              Dim ConnectionInfo As ConnectionInfo = New ConnectionInfo()
              ConnectionInfo.DatabaseName = my database
              ConnectionInfo.UserID = login id of user
              ConnectionInfo.Password = user's password
              SetDBLogonForReport(ConnectionInfo, rptopenfiles)
              CrystalReportViewer1.ReportSource = rptopenfiles
         End Sub
         Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
             ConfigureCrystalReports()
         End Sub
         Private Sub SetDBLogonForReport(ByVal ConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
              Dim myTables As Tables = myReportDocument.Database.Tables
              For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
                   Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
                   myTableLogonInfo.ConnectionInfo = ConnectionInfo
                   myTable.ApplyLogOnInfo(myTableLogonInfo)
              Next
         End Sub
    End Class
    I added a hyperlink to one of the existing pages on the website to navigate to this page with the report viewer on it.  When I run the website in Visual Studio and click on the hyperlink I get the following:
    Server Error in '/MyTest' Application.
    The system cannot find the file specified.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The system cannot find the file specified.Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
    &#91;COMException (0x80004005): The system cannot find the file specified.
    &#93;
       CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +126
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +442
    &#91;Exception: Load report failed.&#93;
       CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +513
       CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1378
       CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport() +149
       CrystalDecisions.CrystalReports.Engine.ReportDocument.get_DataDefinition() +85
       CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ParameterFields() +158
       CrystalDecisions.Web.CrystalReportSource.BindControlParameter(Parameter parameter) +130
       CrystalDecisions.Web.CrystalReportSource.DataBindParameters() +191
       CrystalDecisions.Web.CrystalReportSource.EnsureParameters(Boolean forceDataBind) +90
       CrystalDecisions.Web.CrystalReportSource.LoadCompleteEventHandler(Object sender, EventArgs e) +47
       System.Web.UI.Page.OnLoadComplete(EventArgs e) +96
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4086
    Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832 
    Any ideas, anyone?
    Also, assuming I can get past this error, I will need to figure out how to fill the tables in the .xsd dataset file.  I have written a class for the dataset that includes functions that populate the tables in the dataset from the database by executing SQL queries.  But how do I call these functions at the time the report is run?
    This is my first Crystal report written in .NET and I've been struggling with it for days now.  Any help would be most appreciated!
    Thanks very much!
    Chris Severin

    hello, the error message is obviously coming from one of the installed mcafee extensions. please directly contact mcafee technical support - they can likely give you more detailed guidance and are the only ones who can fix bugs or make necessary adjustments in the addon.

  • Open PDF's in new window in document library when using "Find a file" search

    I need to be able to open PDF's in a new window from a document library when using the "Find a file" search built into the document library "All documents" view. I currently have the following javascript on the page:
    _spBodyOnLoadFunctionNames.push("setTargetBlank()");
    function setTargetBlank()
    { $("a[href$='.pdf']").removeAttr('onclick').attr("target", "_blank");
    This works great when going to the document library and navigating through the folders then clicking on a link.
    The problem is when someone goes to the document library then uses the "Find a file" search and then they click on a link. The "Find a file" search does not do a postback (reload) of the page, therefore my javascript to find the PDF links
    and make them open in a new window does not run for the links on the page.
    I have read the following article but this does not seem to offer a solution that will work in this situation for SharePoint 2013 (Office 365): http://social.technet.microsoft.com/Forums/sharepoint/en-US/7ad3224c-3165-47ae-95bc-4f3928e2f9a8/opening-document-library-pdf-in-a-new-window-sharepoint-2013?forum=sharepointgeneral
    I suppose the idea solution would be to somehow tap into the event that is fired when using "Find a file" search to run my javascript and update the links for the search results.
    Can anyone offer any solutions to this issue?

    Hi,
    According to your description, my understanding is that you want to open PDF files in a new window from a document library when using the "Find a file" search.
    As you said, the "Find a file" search does not do a postback (reload) of the page, therefore JavaScript to find the PDF links and make them open in a new window does not run for the links on the page.
    I recommend to use JS link to achieve the goal. Create a JavaScript override file and upload the JavaScript file to the Master Page Gallery, and then set the JS Link property of the document library web part to point to the JavaScript file.
    Here are some links about the JS link in SharePoint 2013 for you to take a look:
    http://www.idubbs.com/blog/2012/js-link-for-sharepoint-2013-web-partsa-quick-functional-primer/
    http://www.learningsharepoint.com/2013/04/13/sharepoint-2013-js-link-tutorial/
    http://zimmergren.net/technical/sp-2013-using-the-spfield-jslink-property-to-change-the-way-your-field-is-rendered-in-sharepoint-2013
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • Firefox can't find the file at (a location is specified) when either "Navigate previous" (and next) buttons are pressed in an HTML5 skin (but OK in IE/Chrome).

    I create HTML5 help projects from a package called MadCap Flare. It uses what they call an HTML5 'skin' that sets the style/layout of the page and also includes 'Navigate previous' and 'Navigate next' buttons. When viewing the help and pressing these navigate buttons in IE8 or Chrome 32 there is no problem, but in Firefox 27 I get the following: (typical error for pressing a button on any page)
    "File not found"
    "Firefox can't find the file at /C:/SVN/FlareEnglishOnLineHelp/Output/HTML5_Help_Modeller_Reference/4attrib/idh_jointinterface_element_meshes.htm?TocPath=Modeller Reference Manual|Chapter 5 : Model Attributes|Meshing|_____2."
    " Check the file name for capitalisation or other typing errors."
    " Check to see if the file was moved, renamed or deleted."
    - Because the files and buttons work in other browsers I'm wondering just what is going on here with Firefox>>>>

    I should correct that last entry and state that the | charactacters are generated automatically in the Toc-Path for each 'book' name in the online help, and are not something manually created, whereas the : characters have come from the TOC book topic names (which were manually entered names and are what we would ideally require). But, because 'previous' and 'next' topics within nested TOC books without colon (:) characters CAN be browsed successfully when just | characters are present in the Toc-Path, the limitation would appear to be solely due to the : characters.

  • My home page is google and it works but when I open a new tab it displays an error message :Firefox can't find the file at chrome://quick_start/content/index.ht

    I've made sure a dozen times that my home page is set correctly, and when I hit the home button next to the search bar it works and takes me right to google BUT whenever i open a new tab i get the error that my page cannot load and the web url that it keeps trying to remember is in the error message:
    Firefox can't find the file at chrome://quick_start/content/index.html.
    of course the last dot is not the url anymore but the end of the sentence for the error message, but i don't ever use chrome ever on my laptop only my cell so what is going on????? help fix god please!!!!!!

    Do you have the FastStart extension?
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

Maybe you are looking for