M
matt
Java guys:
this is my first project at my first job. so pls help if you could.
i am working with a text file with strange format. The file has a lot
of white space between the last line of valid text and the end of
file character. And the file is update frequently. New valid text is
appended behind the original valid text and overwrite some whitespace.
I need to feed this file as an input to an application. but this
application only take files without such whitespace. The application
need to read the file frequently to see whether new text is appended.
if there is, get the appended text.
My initial solution is to convert the original file into a new file in
which the whitespace is truncated. then the application can read the
new file.
possibility 1:
loop
read 1 line of text of original file
write this line to new file
until read the long line of white space
close both file
in this case, what class and method should i use, especially in
examing the white spaces?
possibility 2:
the previous one is not smart because the same text is read and write
each time when the file is read. so is there a way i can just each
time check whether update happens to the file and then just write the
update to the new file? such as in C, a file pointer know the position
of last read. can i do the same in Java or C#? or other ways to do it?
possibility 3:
very unlikely but smarter,
read the file in a stream, truncate the whitespace inside the
stream, then feed the stream directly into the application. but it is
unlikely because i can not change the souce code the application.
any other possibilies to solve this problem?
for all the possibilities, pls tell me what class and method should i
use, sample code and website is extremely helpful.
thanks a lot!!!!!
this is my first project at my first job. so pls help if you could.
i am working with a text file with strange format. The file has a lot
of white space between the last line of valid text and the end of
file character. And the file is update frequently. New valid text is
appended behind the original valid text and overwrite some whitespace.
I need to feed this file as an input to an application. but this
application only take files without such whitespace. The application
need to read the file frequently to see whether new text is appended.
if there is, get the appended text.
My initial solution is to convert the original file into a new file in
which the whitespace is truncated. then the application can read the
new file.
possibility 1:
loop
read 1 line of text of original file
write this line to new file
until read the long line of white space
close both file
in this case, what class and method should i use, especially in
examing the white spaces?
possibility 2:
the previous one is not smart because the same text is read and write
each time when the file is read. so is there a way i can just each
time check whether update happens to the file and then just write the
update to the new file? such as in C, a file pointer know the position
of last read. can i do the same in Java or C#? or other ways to do it?
possibility 3:
very unlikely but smarter,
read the file in a stream, truncate the whitespace inside the
stream, then feed the stream directly into the application. but it is
unlikely because i can not change the souce code the application.
any other possibilies to solve this problem?
for all the possibilities, pls tell me what class and method should i
use, sample code and website is extremely helpful.
thanks a lot!!!!!