[Java] jump n rows in files

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

[Java] jump n rows in files

Post by ayu »

I am building a small database handler for a uni assignment and I need to be able to jump certain amounts of rows in a file without being forced to process (or even read to buffer) the other rows. Does anyone know of any means to jump in a file using Java?

Any help would be appreciated :) Thanks in advance
"The best place to hide a tree, is in a forest"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

hm, well, there is a skip function in java.io.LineNumberReader, but your info is a little too general, what is the condition to make it skip the line? :-k

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Post by ayu »

well there I needed to jump n lines and not one at a time, but that issue has been resolved with another method of reading the lines in the file. Now I need to skip one line at a time instead xD

Right now I need to simply skip a line if the first word (being username) on a line is equal to the one sent as an argument for the function. This has to be done because I am making a "remove account" function for my little database handler.

I haven't found anything that I can use to remove a line efficiently yet, so I am reading all lines to a new file, skiping the one to be removed, and then removing the old database files and renaming the new one. This is highly inefficient, and if there are a lot of accounts it will not work very well, but it's all I could come up with in 20 minutes xF

if anyone else has any other good solutions for removing lines ... it would be nice =p
"The best place to hide a tree, is in a forest"

Post Reply