• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

returning bufferedreader

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a method that creates a bufferedreader and it suppose to return it to the calling class.

However I am having issues.



The method is held in what I call the DatabaseUtil class, in the final version of the program I will be connecting to a SQL database until then I am using a simple flatfile. So I want to keep connections, query, and linereading in the class. However I want the Factory to be able to loop through the fields that are returned

How can I get this to compile. The try block is hanging me up.
 
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No guarantee in this reply, just re-learning Java, but it looks like your method should be returning a BufferedReader, yet you return a string. I guess you should be returning the BufferedReader instead.

Apologies if I'm wrong.

Mike
 
Michael Hildner
Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Duh, that wasn't right. You're assigning msgString to a BufferedReader, but how is msgString declared? What's the compiler message? Should be a BufferedReader?
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I get this to compile. The try block is hanging me up.

How so? Are you getting an error message? If so, what is it?
 
expectation is the root of all heartache - shakespeare. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic