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

Input files???

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You guys I have a question. I'm trying to write this program, and so far, it's doing mainly what I want it to do, except for one part where I ask the user to input their file name. When they input their file name, (assuming they enter the correct file name), it's supposed to bring up on the screen what's on that file. And so far it DOES do that, BUT, I accidently entered a wrong file name and it brings up everything that is in PetRecords.txt. And I can enter 'any' file name and the info comes up.
I know it's something simple to fix this.

And I'm thinking it needs to be fixed around this area:

BufferedReader inputStream = new BufferedReader (new FileReader("PetRecords.txt"));

Take a peek at my code and see what you think.




I swear my code always looks so goofy when I paste it on here. Shoot.

Anyway, I'd appreciate any help or tips you could give me. And remember talk in 'small' talk because I surely don't know the 'big' stuff yet like you guys do.

HUGS to all!
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh my code doesn't look so bad after all now that I look at it. Ha.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Um...If you're always specifying that it reads PetRecord.txt, then that's what its going to do. You are specifying a constant value instead of a variable.

Try this line:



Of course, that's not going to work on the line where it's currently declared. You'll have to move it after the declaration of fileName.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh hey, thank you, thank you, thank you!!! I had actually wrote that line of code and removed the PetRecords.txt and put fileName there, but I didn't move the actual code to a different place. Yeahhhhhhhhhhhhhhhhhhhhh, thank you for giving me a tip....
THANK YOU, THANK YOU, THANK YOU!!! :jumpingjoy
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic