aspose file tools*
The moose likes Beginning Java and the fly likes Input files??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Input files??? " Watch "Input files??? " New topic
Author

Input files???

Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
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

Joined: Oct 14, 2004
Posts: 195
Oh my code doesn't look so bad after all now that I look at it. Ha.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

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.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Rose Evans
Ranch Hand

Joined: Oct 14, 2004
Posts: 195
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

Joined: Oct 14, 2004
Posts: 195
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Input files???