| Author |
how to read line by line and pass each line value to a method
|
uma prem
Greenhorn
Joined: Jun 21, 2010
Posts: 11
|
|
hi,
i have a text file, having one value in each line digitsandnumbers. now once i read it line by line i need to pass each lines value to one staticmethod (class ABC)which takes it as one of the parameter to get me one more id. Please help me,.i am in trouble.... Please help me with the correct code
what i have done so far is
thanks a lot for your time
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
|
TellTheDetails
|
Joanne
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
I don't understand the problem. You obviously know how to write a method, so what you want is a method which takes the line and extracts the UUID from it. Your code already gives you half the methodObviously I don't know how to complete your method for you.
Why are you making all your methods static? Please put spaces before and after binary operators, after commas etc. Your code is hard to read as it stands.
|
 |
uma prem
Greenhorn
Joined: Jun 21, 2010
Posts: 11
|
|
Hi Campbell,
Thanks for your reply,
My problem is :
My bidfilename is bid.txt having one value in each line(1000lines together)
Now in my program, I am passing the entire textfile(bid.txt) to the method, instead of one line at a time.I want help in that
fieldname="+@\\:Identifier:\""+text+"\"";
uuid=ABC.GetUIDByField(pathname,fieldname);//
like when I check in the fieldname parameter inside the method GetUIDbyField of class ABC,the fieldname shows +@\\:Identifier:\""+bid.txt(the entire filename) ,instead of +@\\:Identifier:\""+12134(one by one line value at a time)
hope i am clear of the problem facing
Please reply
|
 |
Sai Hegde
security forum advocate
Ranch Hand
Joined: Oct 26, 2010
Posts: 183
|
|
|
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32644
|
|
|
Still don't understand the problem. What are you doing in that getUID method?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Sai Hegde wrote:
http://www.coderanch.com/how-to/java/AvailableDoesntDoWhatYouThinkItDoes
For files it's usually pretty accurate but that still doesn't guarantee that it works. If your disk is really busy then available() may return 0 even if there's still data available.
A BufferedReader wrapped around a FileReader seems like a better solution. The Javadoc of DataInputStream's readLine() method also suggests using BufferedReader for reading lines.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Sai Hegde
security forum advocate
Ranch Hand
Joined: Oct 26, 2010
Posts: 183
|
|
Nice, Rob! That is a valuable insight. Thanks!
@Campbell
|
 |
 |
|
|
subject: how to read line by line and pass each line value to a method
|
|
|