jeudi 28 mai 2015

How to close a RandomAccessFile

I'm trying to close a RandomAccessFile but resource remain busy.

Code:

public boolean isOpen(RandomAccessFile f) {
        try {
            f.length() ;
            return true ;
        }
        catch (IOException e) {
            return false ;
        }
    }


this.rfmFile = new File(filePath);
try {
this.rfmRandomAccessFile = new RandomAccessFile(rfmFile, "rws");
} catch(Exception e){
}finally{
this.rfmRandomAccessFile.close();
}
while(!isOpen(this.rfmRandomAccessFile));
log.debug("I Finally Closed this RAF");

Log is not showed and thread goes in loop. When I try to access to my resource from shell it gives me "Device or Resource busy".

The only way to access is kill java process.




Aucun commentaire:

Enregistrer un commentaire