• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Help with homework please

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No path file prompt.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Elle dV", please check your private messages for an important administrative matter. Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic