Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TellTheDetails
 
Marshal
Posts: 75695
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
security forum advocate
Posts: 232
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Marshal
Posts: 75695
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still don't understand the problem. What are you doing in that getUID method?
 
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sai Hegde wrote:


https://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
Posts: 232
1
Android Flex Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice, Rob! That is a valuable insight. Thanks!
@Campbell
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic