File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes switch statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "switch statement" Watch "switch statement" New topic

switch statement

Keith Warzak

Joined: Mar 19, 2001
Posts: 2
I am trying to read in from a text file with a readline buffer that reads in the first string. The first string is then used in the switch statement, allowing it to assign the following number of incoming lines from the text file to certain variables and then be printed to the command line. I believe my problem is that I am trying to passed a string value into my switch statement, but I think I need this same value in my "if" statement to determine if it is at the end of the file.
Here is my code:

added UBB CODE tags to preserve indentation
[This message has been edited by Frank Carver (edited March 26, 2001).]
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
There are a few problems with this. First is that you have put quotes around 'type' in the switch, so it is not referencing the string variable, but a constant char variable instead. If what you want is to switch on the first character of the line, then use the following:
insead of
If this is not what you want, then please explain further what behaviour you require.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Keith Warzak

Joined: Mar 19, 2001
Posts: 2
Thank you
I agree. Here's the link:
subject: switch statement
It's not a secret anymore!