• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Refreshing a directory in java

 
Ranch Hand
Posts: 68
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i refresh a folder using java codes?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing like "folder" in Java. Just a File which can represent an individual file or a directory path
What do you mean "refresh" Please TellTheDetails
 
Nidheesh Krishna
Ranch Hand
Posts: 68
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to compare two files. First file is already existing file and second file is an unzipped one to the same location. But when i pass this two files to the method(method which handles comparison) after unzipping second file, i'm getting FileNotFoundException for second file.
This occurs immediatlly passing files to the method after unzipping second one.

Before passing to the method, i added the code,




passed this thread to the method and stopped the thread in the method which handles the comparison.



Now the FileNotFoundEXception removed.
Is there any logic mistakes in using thread to remove the problem?
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget the thread code for the moment. I am confused with this

Nidheesh Krishna wrote:First file is already existing file and second file is an unzipped one to the same location. But when i pass this two files to the method(method which handles comparison) after unzipping second file, i'm getting FileNotFoundException for second file.
This occurs immediatlly passing files to the method after unzipping second one.



Consider the directory /test
Do you mean to say, under /test you have a file called say File.txt and another file called say archive.zip. Archive.zip contains another file called File.txt. Is that correct?
 
Nidheesh Krishna
Ranch Hand
Posts: 68
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
directory /test  contains First.txt and another file second.txt.
second.txt is actually coming from an zip file which is available in another location. unzipped the zip file to /test.
Now i have two files first.txt and second.txt in /test . passing this two files two another method.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Windows filesystem (and filesystems on other operating systems in general) don't have the notion of "refreshing" the contents of a folder or directory.

The "refreshing" that you are thinking about is a feature of Windows Explorer, or some other program that lists the content of a directory and shows it on screen. When you try to access a file and you get an error saying that it's not there, then that file is really not there. You don't have to "refresh" anything (in fact, you can't, because this is not how the filesystem works).

So, your problem is caused by something else, and not because you need to refresh the content of a directory. Maybe the filename or pathname that you are using is wrong.
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And don't use thread.stop, it has been deprecated since a long, long time ago (in a galaxy far far away). You can find more information on http://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Random thought - are you sure you closed the unzipped file?
 
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic