File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Perl and the fly likes Error 35 Resource Temporarily Unavailable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Perl
Bookmark "Error 35 Resource Temporarily Unavailable" Watch "Error 35 Resource Temporarily Unavailable" New topic

Error 35 Resource Temporarily Unavailable

a elmas

Joined: May 14, 2011
Posts: 13
I'm calling a method, scrTm(), many times in a loop. In this method it executes a perl script called "". needs two input files, "s1.seq" ve "s2.seq". I write these files in the same method, scrTm(). Method basically takes two character arrays as inputs(seq1 and seq2) and writes them into files "s1.seq" ve "s2.seq".

At first steps(up to around 100) the perl script is executed with no problem, however when the number of steps increase it gives an exception as:

I guess, I am ensuring that the files are written correctly and it is an issue of memory. There should be a simple solution to this, but I'm new in Java.
Please help me how to fix it.

Here is my code:

James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Is there some reason why you don't close stream 'out1' and 'out2' ? These streams are are still open when you use the associated files though Runtime.exec().

P.S. When you chain streams as you are doing you only need to close() the outer stream since this is required to propagate through to the chained stream.
P.S.1 You should not need to flush() a stream before closing it since the contract for close() says it should perform a flush() before actually closing.
P.S.2 You should close streams in a finally() clause to make sure that even if you have exception the streams are closed. This is a simplification of the standard forceClose() method I use in most of my work.

It can be used on all Java streams since they all implement Closeable.
P.S.3 Your use of Runtime.exec() is seriously flawed. See

Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
a elmas

Joined: May 14, 2011
Posts: 13
James Sabre wrote:
P.S.3 Your use of Runtime.exec() is seriously flawed. See

Thanks for reminding the open files, but it did not fix the problem alone. I looked the web-page you referred, it is a good trouble-shooter for Runtime.exec().
Using the StreamGobbler class mentioned there fixed all the problem. It seems like flawless for now.

Thank you so much!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

a elmas,
Your post was moved to a new topic.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: Error 35 Resource Temporarily Unavailable
It's not a secret anymore!