Click here to Skip to main content
16,011,374 members
Home / Discussions / Java
   

Java

 
Questionnetbeans Pin
tksrules22-Jan-09 22:47
tksrules22-Jan-09 22:47 
QuestionJava questions Pin
tksrules22-Jan-09 22:46
tksrules22-Jan-09 22:46 
AnswerRe: Java questions Pin
Reagan Conservative29-Jan-09 11:42
Reagan Conservative29-Jan-09 11:42 
QuestionSending a newletter as an Email [modified] Pin
peaceful_warrior20-Jan-09 18:45
peaceful_warrior20-Jan-09 18:45 
AnswerRe: Sending a newletter as an Email Pin
Swapnil Gholap27-Jan-09 22:09
Swapnil Gholap27-Jan-09 22:09 
QuestionCopy file from one folder to another Pin
PeterPan92919-Jan-09 18:09
PeterPan92919-Jan-09 18:09 
AnswerRe: Copy file from one folder to another Pin
PeterPan92921-Jan-09 21:47
PeterPan92921-Jan-09 21:47 
Questionnoob Needs help with File Handles and VM RAM Pin
TylerD7519-Jan-09 6:03
TylerD7519-Jan-09 6:03 
I'm not sure if this is the right forum, as this might be related to either NFS or the underlying FS, but anyways...

I'm going through a number of Folders to find subfolders and the files in those subfolders:
Media_Folder1
    |-> subfolder_1 -> File1, file2, etc...
    |-> subfolder_2 -> File1, file2, etc...
Media_Folder2
    |-> subfolder_1 -> File1, file2, etc...
    |-> subfolder_2 -> File1, file2, etc...
...


I use the following code:
File rFolder = new File("/Media_Folder/");
File[] subFolderArray = rFolder.listFiles();
for (int i = 0; i < subFolderArray.length(); i++) {
     if (subFolderArray[i].isDirectory()) {
          // For each subfolder I'll enter it, and add each file to a custom file class array
          File[] tmpFolderContent = subFolderArray[i].listFiles();
          for (int i2 = 0; i2 < tmpFolderContent.length(); i2++) {
               myCustomFileClass tmpCustFile = new myCustomFileClass(tmpFolderContent[i2].getPath());
          }
          .... // etc...


The problem is that the code above (or a bit more complicated version) is working fine, until a certain point.
Then suddenly the tmpFolderContent array gives a nullpointer exception.

1. The code above (...and then some) creates a MediaObject that contains a StringArray that holds names of all subfolders.
2. Then the code goes through all those subfolders to create a CUSTOM FileObject array (Not the regular java.IO.File class, but a custom one that holds only enough info to create a new java.io.File object). The Custom FileObject ARRAY holds the filename and path of all files in all subfolders.
3. The number of files in each subfolder is never more than 25-30, and the number of subfolders is never more than 10, but the number of MediaObjects is fairly large (450++).

There are some ways I can go around this problem (Like add each object to the database right after it's creation [which is what I want anyways, although I want to do something more with the objects before I do this], but this means creating the objects, store them in DB, read them from db and then change them accordingly).
But I'd rather know what is causing this problem, so I know WHY I need to do it that way Wink | ;) .

The strange thing is that it appears on the same media folder, and the exact same subfolder each time.
If I skip this folder, it happens on the next subfolder. So something is reaching it's limit.
I've also tried running the above code on ONLY the failing folder, and then it works just fine. So it's not access restrictions on the folders in question!

At first I thought it was the FileArray that had reached its end, but it has room for a lot more (I amped it up after hitting this problem).
Then I thought it could be the MediaObjectArray that had reached it's end, but after increasing it nothing changed.

So this leaves me 4 more possibilities:
1. The VM runs out of RAM? If so, how do I find/change the amount of RAM set aside for the VM (on Gentoo Linux)?
2. There's a limit to the number of file handles the VM can handle? If so, is there a way to change it?
3. Can the number of available FileHandles be defined by the underlying file system (In this case it's a remote NFS share on ReiserFS & XFS FS).
4. Or am I barking up the wrong tree here? Is there something obvious I'm not seeing here (as it often is Wink | ;) ).

I guess it's not very good programming practices to create this many objects and to keep them in RAM like this, but I want to do some more stuff with the objects before they're added to the DB...and RAM means less waiting...
And this is my first Java Project, so give me some slack Wink | ;)

Cheers,
Martin
AnswerRe: noob Needs help with File Handles and VM RAM Pin
Reagan Conservative29-Jan-09 11:48
Reagan Conservative29-Jan-09 11:48 
AnswerBased on the code you provided... Pin
Naruki9-Feb-09 15:47
Naruki9-Feb-09 15:47 
QuestionAsking for helps about the GUI JAVA ... Pin
SantoKisVa19-Jan-09 3:12
SantoKisVa19-Jan-09 3:12 
AnswerRe: Asking for helps about the GUI JAVA ... Pin
Reagan Conservative20-Feb-09 6:38
Reagan Conservative20-Feb-09 6:38 
Questionprogram smart card to keep patient information Pin
fresh2g618-Jan-09 4:36
fresh2g618-Jan-09 4:36 
AnswerRe: program smart card to keep patient information Pin
Garth J Lancaster18-Jan-09 10:26
professionalGarth J Lancaster18-Jan-09 10:26 
QuestionFind numbers in a given string Pin
eng_maioia17-Jan-09 1:49
eng_maioia17-Jan-09 1:49 
AnswerRe: Find numbers in a given string Pin
toxcct19-Jan-09 1:41
toxcct19-Jan-09 1:41 
QuestionBest Method to Write ArrayLists Pin
Reagan Conservative15-Jan-09 8:34
Reagan Conservative15-Jan-09 8:34 
AnswerRe: Best Method to Write ArrayLists Pin
newbie_15-Jan-09 20:04
newbie_15-Jan-09 20:04 
GeneralRe: Best Method to Write ArrayLists Pin
Reagan Conservative16-Jan-09 3:55
Reagan Conservative16-Jan-09 3:55 
QuestionExtract metadata from WMV file using Java Pin
Java Developer - First Time15-Jan-09 6:32
Java Developer - First Time15-Jan-09 6:32 
GeneralRe: Extract metadata from WMV file using Java Pin
itsmani27-Jan-09 20:51
itsmani27-Jan-09 20:51 
AnswerThe very first step has nothing to do with Java. Pin
Naruki15-Feb-09 17:24
Naruki15-Feb-09 17:24 
Questionread coulm from file and store it to array Pin
newbie_15-Jan-09 3:05
newbie_15-Jan-09 3:05 
Question[Message Deleted] Pin
Michael Monin14-Jan-09 10:02
Michael Monin14-Jan-09 10:02 
AnswerRe: Simple java programming Pin
toxcct15-Jan-09 4:29
toxcct15-Jan-09 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.