🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #104

Re: Too many open files error thrown from java.io.File

#104
From: Lori M Olson (TeamB)
Date: Sun, 04 Apr 2004 20:45
50 lines
2785 bytes
Scott wrote:

> Hi,
> 
> I'm using an MP3 class library from http://www.vdheide.de/projects.html.  It
> is the same library in the J-Jukebox project.
> 
> The library offers a set of classes to read MP3 files.  The main class is
> MP3File, which extends File.
> 
> I've got code that scans all of my MP3 and looks for those that have ID3
> tags (the older way to mark the artist, song title, etc. in the MP3 file).
> The code appears below.
> 
> I've got about 1800 files to scan.  At file # 897, I get a
> java.io.IOException: Too many open files.
> 
> Can anyone suggest how to avoid this problem (aside from only handling 897
> files at a time)?  If there was a File.close() command, I'd happily execute
> it.

Your MP3 library is flawed in this respect.  In the ID3 class, the 
checkForTag() method opens a file and fails to close it.  You'll need to 
fix that method if you want to get past this problem.

Since you are new to programming, I'll give you a hint for making this 
fix simpler ... it is considered bad programming practice to have 
multiple return statements within a method.

Poking thru the source also reveals that new MP3File() will create a new 
ID3 object.  So you probably don't need to create one yourself.

-- 

Regards,

Lori Olson (TeamB)

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Technical Details
Message-ID: <407073e5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <406edc6e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,606a3d8ee4cf8a04
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2004-04-04 14:09:37 PST
Date: Sun, 04 Apr 2004 14:45:11 -0600
From: "Lori M Olson (TeamB)" <javadragon@techie.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax; CDonDemand-Dom)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Too many open files error thrown from java.io.File
References: <406edc6e$1@newsgroups.borland.com>
In-Reply-To: <406edc6e$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 142.179.181.200
Message-ID: <407073e5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081111525 142.179.181.200 (4 Apr 2004 13:45:25 -0800)
Lines: 51
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsrout1.ntli.net!news.ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail