• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with homework please  RSS feed

 
Elle de Vasquez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have to create a program that reads a file that I've created...this part's easy, done...but I also have to have the user input the name of the file in order to grab it. It's partly working lol...I want the program to catch wrong file names...and the program runs with whatever I enter...and it's driving me crazy! Help please!



Here's the code for he helper method getStringFromUser I have in a library I created:

 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want the program to catch wrong file names...

If by that you mean you want to notify user that the path provided doesn't lead to a file:

and the program runs with whatever I enter...

Whatever you enter, your program reads the same file:
 
Elle de Vasquez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kemal Sokolovic wrote:
I want the program to catch wrong file names...

If by that you mean you want to notify user that the path provided doesn't lead to a file:

and the program runs with whatever I enter...

Whatever you enter, your program reads the same file:


No, I want to notify the user that the file name he entered is wrong...oh right, obviously it would lead to the wrong path file for you since I didn't provide the file...but yeah...just that he entered the wrong file name.

I mean, whatever I entered at the prompt for the file name...like, if I enter Halt...it'll display the file anyway. I hope I'm making sense.

Thanks for responding so uickly!
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I want to notify the user that the file name he entered is wrong...

Again, if there isn't some additional condition that I don't know about whether or not the filename is wrong, I already suggested what you should do.

I mean, whatever I entered at the prompt for the file name...like, if I enter Halt...it'll display the file anyway.

Whatever you enter in prompt you will read file specified at line 8 of your first code:

so it doesn't really matter what you entered. Are you prompted to enter path to a file you want to open, or something else?
 
Elle de Vasquez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No path file prompt.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Elle dV", please check your private messages for an important administrative matter. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!