2

I have very strange issue. When I want to list files from shared folder (windows server 2003), my code blocks on listFiles() method (no exception, no ends, just blocks on that line). I am using Common IO 2.3 library.

When I create the same application in Delphi it successfully lists the files (using the same windows user as java).

Is there any restrictions on shared folder in java?

Java code:

File folder = new File(args[0]);
List<File> files = (List<File>) FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, new RegexFileFilter("^(?!_).+"));//new RegexFileFilter("^((?!\\_).)*$")
skaffman
  • 398,947
  • 96
  • 818
  • 769
Nikola
  • 624
  • 1
  • 14
  • 31
  • what is the stacktrace of your program when it blocks? – jtahlborn Apr 28 '12 at 13:31
  • This is how you can do same in java - http://stackoverflow.com/questions/2171822/connecting-to-shared-folder-in-windows-with-java – Subhrajyoti Majumder Apr 28 '12 at 13:33
  • I cannot access stacktrace since it is executed on server (where I don't have env only jre). Do you know any other way to see stacktrace on server mashine? – Nikola Apr 28 '12 at 13:35
  • @Quoi I don't connect to remote server, java is executed on the server which shares its file system folder. – Nikola Apr 28 '12 at 13:36
  • you could enable [remote jmx connection](http://docs.oracle.com/javase/1.5.0/docs/guide/management/agent.html#remote) on the server and connect to the server using jvisualvm. – jtahlborn Apr 28 '12 at 13:41
  • can you please provide stack trace.Ideally No change is required in Java code. – Subhrajyoti Majumder Apr 28 '12 at 13:43
  • @jtahlborn The problem is that I only can access to that server via TeamViewer (no other port are open). Keep in mind that there are 300k+ files in that folder and machine doesn't have good performance. Maybe listFiles() takes too long to finish?? – Nikola Apr 28 '12 at 13:48
  • What about [File.canRead()](http://docs.oracle.com/javase/7/docs/api/java/io/File.html#canRead%28%29)? Does it give you anything? Or maybe .exists()... – Petr Janeček Apr 28 '12 at 13:56
  • @Slanec Both true. Also values for canWrite(), canExecute() and isDirectory() are true. – Nikola Apr 28 '12 at 14:00
  • @Nikola Cool stuff. `FileUtils.listFiles()` uses `File.listFiles()` internally, try that one (to see that it blocks on this operation, too, 'cause then we're screwed :) ). If the directory has _tons_ of files, then yes, maybe it's just superslow. No idea on that without access to the machine running the program =/. A blind shot: [DirectoryStream](http://docs.oracle.com/javase/7/docs/api/java/nio/file/DirectoryStream.html). – Petr Janeček Apr 28 '12 at 14:06
  • I tried with subfolder with 2000 files and it takes 9 seconds to unblock. After that, I tried again and it unblocks in less than 1 sec (probably OS caches files information which is needed for listFiles() method). Any idea now? – Nikola Apr 28 '12 at 14:11

0 Answers0