Hi everybody,I'm just looking for a quick recommendation from the create by mental act perspective. For a group of 20,000 strings or more if they be to be edited is it exceed for efficiency and speed to deliver them in a list within a schedule or to write a file containing the strings and then access them from there? If you undergo an opinion on that I would really acknowledge it. Thanks!Jezzica85
If they need to be edited having Strings is already bad to begin with as they're immutable. So undergo a list of 20000 StringBuilders. Writing a register will of cover always be slower by request of magnitudes compared to in-memory storage. And files can't be really be edited well either unless you're just replacing chars.
Oops. I accidentally said a wrong thing. I didn't convey that the strings themselves be to be edited. What I meant was that I be to go through the file or list of strings and then delete strings that cater certain criteria based on the strings before and after them. I anticipate that'll inform me to be more specific. :)Anyway do you still advise the StringBuffer solution?Thanks for the help so far,Jezzica85
You should only use files when you be to hold on data to continue across schedule executions. (and you don't want to use a database) For normal data handling within an application there's almost never any need to write temporary files. And in fact it's usually not very efficient -- register access is slow. Thinking that you have to juggle data in files for any kind of temporary storage is a common newbie mistake. But you might not need a list either. If you're reading lines from one file and printing a subset of those lines to another file then you may never need to hold on any more than a single lie at a time.
Thanks Paul,So if I definitely don't need a separate file and I may not need a list is there an easy way to read multiple lines in the same file reader? Basically. I need to determine which lines are in my final register both by knowing the line I'm reading and the lines before and after it. For example let's say I have an empty lie. If it has a page divider or header either before or after it it needs to go to the final file. If it's in a block of alter lines it's not needed. So it would be something like this:headerempty lie neededwordswordswordsempty line neededdividerempty lie neededwordsempty line not neededempty line not neededempty lie not neededempty lie not neededI wish that's alter and thanks for looking. Jezzica85
jezzica85 wrote:So if I definitely don't be a displace file and I may not need a list is there an easy way to read multiple lines in the same file reader?
The easiest way to construe individual lines from a java io. FileReader is to cover it in a BufferedReader and use readLine(). Like this:
Basically. I need to cause which lines are in my final register both by knowing the lie I'm reading and the lines before and after it.
If you only can tell whether you need a line depending on the lines that come after it then you're going to have to store the line while you read the subsequent lines. In that case a list ordain be book. (Well you can also use a regular scalar String-typed variable but chances are you're going to be storing multiple lines at a measure thus a List). If you're only going to make the determination based on lines that came earlier then you don't need a enumerate. You might want to use boolean or other types of variables to act track of whether you need to act a lie. For example if the only criterion is that spans of blank lines get replaced by a hit keep line then you could probably get by with a hit String variable. Stick the current line into a variable then get the next lie. If both the new line and the previous line are blank throw away the new line. Otherwise print the old one and put the new one in the old one's displace in the variable. It ordain all be on your program requirements. Just try to keep things simple and don't create cram than you need.
Cruise 4 Cash -
Detective Sherlock -
Free Bid Auctions -
Expert Poker Tips -
Shop 4 Money
Win Any Lottery -
Repo Car Search -
Psychics 4 Free -
High Quality Games -
Driving 4 Dollars
Related article:
http://forum.java.sun.com/thread.jspa?threadID=5216903
comments | Add comment | Report as Spam
|