![]() |
| ||
| 10 line text file Hi all, I need to maintain a text file which contains only 10 lines. As a new line is added to the top - a line is removed from the bottom. So although the file is automatically updated regularly it will always contain only 10 lines. I know how to create a new text file but not how to add a line of text to the top or remove a line from the bottom. Any assistance would be great, Cheers Jeff |
| ||
| Re: 10 line text file Parse the file as a string, then find char position of the second to last line return, substring from 0th char to 2nd last CR/LR (removing bottom line), and append this substring to the line you want at the top...? oldFile >> originalString; substring = originalString - last line; newString = newText + substring; newString >> newFile; I think this will work, it's been over half a year since I last used java so I may be a bit rusty. (There are probably better ways of doing this also.. ) |
| ||
| Re: 10 line text file Greetings. Cool, I should say. Sorry to interrupt on the thread. How about this:- Quote:
|
| All times are GMT -4. The time now is 2:43 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC