Article View: borland.public.jbuilder.java.language
Article #8575Sorting problem - on file...
From: Paul Linehan
Date: Wed, 14 Mar 2001 19:37
Date: Wed, 14 Mar 2001 19:37
48 lines
1907 bytes
1907 bytes
Hi all, I have a file with the following data in a file called blah.txt Ams3vh45 1 0 Onm6io99 2 0 Nny5ev37 3 0 Yka5vj88 4 0 Ttr2yb07 5 0 Now, I wish to sort this file by the first field (I *_cannot_* use memory - it *_has_* to be on disk), so my thinking is: Read in first record of blah.txt - if first record write to index file blah.inx. Arrive at second line in blah.txt Start reading blah.inx. Determine the point in blah.inx I have to insert the second record. Close blah.inx. Start reading the records in blah.inx into a temporary file blah.tmp. When I arrive at the point in blah.inx where the new record has to go, I insert my new record into the file. I add the rest of the records to blah.tmp. I then overwrite blah.inx with blah.tmp, and move to the next record in blah.txt. I believe that this algorithm is correct - the only problem is that I don't really know how to start translating it into java what with all the FileBuffers, Buffered readers and all sorts of different I/O classes that are out there. Any help in this direction much appreciated. Paul...
Technical Details
Message-ID:
<3aafc81c.117997371@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!193.120.178.201Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,5a829ab327e2677b,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-14 11:48:26 PST From: paul@esat.net (Paul Linehan) Newsgroups: borland.public.jbuilder.java.language Subject: Sorting problem - on file... Date: Wed, 14 Mar 2001 19:37:19 GMT Message-ID: <3aafc81c.117997371@newsgroups.borland.com> X-Newsreader: Forte Free Agent 1.21/32.243 NNTP-Posting-Host: 193.120.178.201 X-Trace: 14 Mar 2001 11:39:00 -0800, 193.120.178.201 Lines: 51 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!193.120.178.201