Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

isDirectory() incorrectly returning false

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In System - A, i listed the files of a directory(using listFiles()) and store that object in a serialized format
In System - B, i've deserialized the file and iterate the file object. the isDirectory() method always return false here..It works perfectly on System - A
 
Sheriff
Posts: 67636
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Laxman Guru", please check your private messages for an important administrative matter.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure the directories are also present int he System B.

Because when you create a file instance it will point to the path(if present) during run time else if you use any of the method like isDirectory or isFIle it will return false.
 
Sheriff
Posts: 22647
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Siva is right. Just because you have serialized a File object doesn't mean it has serialized the folder structure and file contents. You will have to do that manually, in which case creating a ZIP file with the contents will probably be more useful. Do a search on how to recursively ZIP a folder; that question has been asked before here.
 
Laxman Guru
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies,

creating a ZIP file with the contents will probably be more useful

are you advising me to zip the entire content of the folder?
ohh! that can not be possible in my case.i am creating file explorer like application which displays the remote m/c files in a tree format.

Make sure the directories are also present int he System B


no it doesn't..so that i need to create a object,put the files details and serialize it...any other ideas?
 
Rob Spoor
Sheriff
Posts: 22647
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a custom FileObject class that copies this data. For example:
The only thing that will be trickier is listing children on the local machine. It will need to go to the remote machine to retrieve new FileObject objects.
 
Goodbye moon men. Hello tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic