• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read line by line and pass each line value to a method

 
uma prem
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TellTheDetails
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 212
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still don't understand the problem. What are you doing in that getUID method?
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sai Hegde
security forum advocate
Ranch Hand
Posts: 212
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice, Rob! That is a valuable insight. Thanks!
@Campbell
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic