Newbie here having input problems

Hi, I'm still very new to Java and I'm basically learning it on my own right now. I think my current problem is with the way I'm reading in the input. Since my entire program right now is over 100 lines, I'll only post how I'm reading input in, and how I'm trying to use the input to continue program execution so that I can verify first if my input is correct before I move on to posting snippets of my program. Here's what I'm trying to do:
//Begin code here
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String cmd="";
while(//condition)
//Print out input options here
//Read input here
cmd = in.readLine();
cmd.trim();
if((cmd == "A') || (cmd == "a"))
      //Process
else if((cmd == "S") || (cmd == "s"))
        //Process
else if((cmd == "B") || (cmd == "b"))
     //Process
else
      System.out.println("Command not recongnized");
}Based on that code above, is the input reading being done correctly? That's the idea of what I'm trying to do in my program, yet it always just says that it doesn't recognize the command. If need be I will start to post more of my code if this example is not sufficient enough. I'm sorry if this is another one of those cookie cutter answer questions, I've just become somewhat frustrated in the last few hours of trying to figure out why my program isn't working. Thank you for any help you may be able to provide.

Shoot, sorry didn't read over my post before posting as I should have. The snippet:
if((cmd == "A') || (cmd == "a"))
      //Process
}Should read:
if((cmd == "A") || (cmd == "a"))
//Process
Sorry about that.

Similar Messages

  • Newbie here: Fire Wall problem with Creative Cloud?

    Hi All:
    Thanks in advance for your help!
    I recently paid for the Creative Cloud. My problem is that I cannot log into the program from the Wi-Fi network at a friend's house. I was using the same computer I signed up with and paid for the Creative Cloud. But obviously the ISP was not the same.
    I did not have any problems with other cloud based programs (SalesForce, Picassa, Flickr). My friend tried different settings with her Firewall but nothing worked
    So, is this a firewall issue  on the server side of Creative Cloud? Are there other settings I should check?
    Thanks!
    Judith

    HI Judith,
    Is the behavior occuring from all programs? Are you getting some kind of error message?
    Thanks,
    -Dave

  • My daughter's older Ipod Touch is having a problem with images becoming pixilated when taken from an e-mail and placed into her camera roll. ( She wants to put on Instagram ) Any help?

    My daughter's older Ipod Touch is having a problem with images becoming pixilated when taken from an e-mail and placed into her camera roll. ( She wants to put on Instagram ) Any help?

    I think that may be a consequence of the email provider she is using. Some services (AOL is one example) inspect and modify email attachments, particularly photos, resulting in reduced resolution compared to the email that was sent.
    The iPod does not do this. The resolution of the picture in the email she receives will be identical to what is imported.

  • Hi I just got my iPad 2 and updated it to ios7 . Here is my problem: my Chinese input doesn't work , I need to restart every time . Is it the problem of the iPad? Or iOS 7??

    Hi I just got my iPad 2 and updated it to ios7 . Here is my problem: my Chinese input doesn't work , I need to restart every time . Is it the problem of the iPad? Or iOS 7??

    Hi Eric Ferguson,
    Thanks for using Apple Support Communities.
    For troubleshooting on this, take a look at this article:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/ts3694
    Error 13, 14, 35 and 50 (or -50)
    These errors are typically resolved by performing one or more of the steps listed below:
    Perform USB isolation troubleshooting, including trying a different USB port directly on the computer. See the advanced steps below for USB troubleshooting.
    Put a USB 2.0 hub between the device and the computer.
    Try a different USB 30-pin dock-connector cable.
    Eliminate third-party security software conflicts.
    There may be third-party software installed that modifies your default packet size in Windows by inserting one or more TcpWindowSize entries into your registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet-size modification for assistance. Or, follow this article by Microsoft: How to reset Internet Protocol (TCP/IP) to reset the packet size back to the default for Windows.
    Connect your computer directly to your Internet source, bypassing any routers, hubs, or switches. You may need to restart your computer and modem to get online.
    Try to restore from another known-good computer and network.
    Best of luck,
    Mario

  • Since the Kit Kat update every time I am on a call I here a Beep on my phone every 30 seconds very annoying anyone else having that problem.

    Since the Kit Kat update every time I am on a call I here a Beep on my phone every 30 seconds very annoying anyone else having that problem.

        Thanks for the information DiGravio1! Let's look further into this. Please navigate to Settings>My Device>Call>Call Alerts>Under Call Status Tones Un-check alerts>Power off/on, test and share. Thank you.
    TominqueBo_VZW
    Follow us on Twitter @VZWSupport

  • If you are having a problem start here!

    Lots of problems right now due to Apple server issues.
    Apple is having server problems affecting App Store, iTunes, iCloud, etc…
    Check the Apple Service Status(***) page… http://www.apple.com/support/systemstatus/
    Wait for all systems green. This is always a good idea if you have problems with anything Apple.
    Here is what Apple message says…
    Multiple Store Services - All users are affected
      Customers may be unable to make purchases from the App Store, iTunes Store, iBooks Store, or Mac App Store.
    iCloud Mail - All users were affected
      Users may have been unable to access iCloud mail.
    iCloud Account & Sign In - All users were affected
      Users may have been unable to sign in.
    This means no downloads, updates, iCloud and other issues. You may get pop-up windows asking you for password for iCloud, etc…
    Wait, try again after all green on status page.
    Hope this helps, Greg

    Thank you very much! Great advice - I just had the described problem, and tried what you had described. It works! And now the optical drive showed up as well...

  • I am unable to forward my photos through iMessage here lately. I have iPhone5 and started having this problem within last month. Anyone have a solution I can try?

    I have been unable to forward photos and videos within the last month on my iPHone 5. Anyone else having this problem and does anyone have a solution?

    Hello,
    I found the exact solution. It is very simple thank you. But I want to remove the passcode on my phone can anyone help me.
    Thanks
    Srini.

  • [multithread] newbie here ... is inputStream shared?

    Hi, a newbie here. I've been playing with java for six month now and it's been pretty fun. Looking forward to learn more about java from this forum. Now I have a question about this little project I've been doing.
    I'm currently developing a multi-threaded client-server application (both client and server are multi-threaded). The idea is very easy which is to create threads that send http request to one server which will send back XML to the
    corresponding thread.
    I've managed to make it work. My application can now make http request and get the XML it's looking for. However, problem occurs when I try this scenario:
    1. Client Thread 1 http request> server -> creates server thread 1
    I made Server Thread 1 sleep for awhile so Client Thread 1 has to wait for the response.
    Then, while Server Thread 1 is still on sleep, I make another http request:
    2. Client Thread 2 http request> server -> creates server thread 2
    I again Server Thread 2 sleep for awhile so Client Thread 2 has to wait for the response.
    Now, Server Thread 1 wakes up and returns the XML response message. Now the funny thing is the Client Thread that accepts this response is not Client Thread 1, but Client Thread 2:
    3. Server Thread 1 wakes up -- XML response --> Client Thread 2 reads the response instead of Client Thread 1.
    What could be the problem!? What's also weird to me is that, if I try to do this scenario using a browser (by executing http request), the problem doesn't happen. Client Thread 1 returns to Server Thread 1 and Client Thread 2 returns to Server Thread 2.
    The code I wrote consist of a thread objects which has it's own private UrlConnection, InputStream, OutputStream, etc.
    This is a snippet of my code:
    public class Process {
    // this is how I create my threads
    public void execute(DataSource datasource, ADData ad)
    HttpProcess httpRequestor;
    try
    httpRequestor = new HttpProcess(datasource,ad);
    httpRequestor.start();
    catch (Exception e)
    e.printStackTrace();
    public class HttpProcess extends Thread {
    private URL url;
    private HttpURLConnection urlConn;
    private DataSource ds;
    private ADData adData;
    private BufferedReader d;
    private BufferedWriter t;
    private InputStream in;
    private OutputStream out;
    private DataInputStream din;
    private DataOutputStream dout;
    public HttpProcess (DataSource datasource, ADData ad)
    this.ds = datasource;
    this.adData = ad;
    // this is how I implement my run method
    public void run ()
    try
    String urlmsg = "http://localhost:9050" +
    "/?field1=" + adData.getField1()+
    "&field2=" + adData.getField2()+
    "&field3="+ adData.getField3();
    System.out.print("Sending URL message : " + urlmsg);
    url = new URL(urlmsg);
    urlConn = (HttpURLConnection)url.openConnection();
    urlConn.setRequestMethod("GET");
    urlConn.setDoOutput (true);
    urlConn.setRequestProperty("Content-Type",
    "application/x-www-form-urlencoded");
    out = new BufferedOutputStream(((HttpURLConnection)urlConn).getOutputStream());
    dout = new DataOutputStream(out);
    t = new BufferedWriter(new OutputStreamWriter(dout));
    t.flush();
    while(listening)
    in = new BufferedInputStream(((HttpURLConnection)urlConn).getInputStream());
    din = new DataInputStream(in);
    d = new BufferedReader(new
    InputStreamReader(din));
    String inputStr;
    if ((inputStr = d.readLine())!=null)
    din.close();
    XMLParser xmlparser = new
    XMLParser(ds,adData,ajData);
    listening = false;
    d.close();
    I thought I had it right by having private inputStream for each thread. but the behavior looks like the inputStream is shared by the two threads. However, I'm still new with java so I know my conclusion worth zero. Has anybody ever bumped into this kind of problem? Looking forward to hear back what you guys think. I'm just really really really curious about this problem
    Thanks so much.

    Please use code tags ([code] and [/code]). It's also quite possible the problem is in your server code, or your test jig, etc. You should post a small example that replicates your problem.
    Also, the while(listening) loop looks really screwy. I'm not sure what's going on there (why would you wrap your input stream inside a loop, especially since you close the input stream in the loop)?

  • Hi newbie here  . .

    Hi everyone
    (Sorry if this post is in the wrong thread but am just getting sorted).
    Newbie here and having just swapped from a Windows machine to my mac I am finding a problem with itunes.
    Please in words of one syllable . . could some one please say if using the "Open Stream" in advanced icon will allow me to connect to BBC local radio?
    If so, please could they say how?
    Ta
    ibook    

    Hi Macadam_ace,
    Welcome to Apple Discussions
    Do they have their show on the internet? The iTunes Help document says,
    "If you know the Internet address (URL) of an MP3 streaming broadcast, you can connect to it using iTunes.
    Choose Advanced > Open Stream.
    Enter the full URL of the file you want to listen to. For example, http://www.apple.com/itunes/sample.mp3."
    I hope that helps,
    Jon
    Mac Mini 1.42Ghz, iPod (All), Airport (Graphite & Express), G4 1.33Ghz iBook, G4 iMac 1Ghz, G3 500Mhz, iBook iMac 233Mhz, eMate, Power Mac 5400 LC, PowerBook 540c, Macintosh 128K, Apple //e, Apple //, and some more...  Mac OS X (10.4.5) Moto Razr, iLife '06, SmartDisk 160Gb, Apple BT Mouse, Sight..

  • Still having navigation problems and need help with how to debug

    Hi,
    I've been porting over a servlet project to JSF and I'm still having navigation problems. I thought the problem might have been because the original project used HTML frames and so the "from-view-id" JSP defined the frame/framesets and the specific JSP that does the submit (and so is named in the "from-view-id" is never defined in a "to-view-id" attribute). I've now switched to using an IFRAME, and that resolves that problem. So now the JSP is defined in a "to-view-id" attribute and it includes an named IFRAME that can be used as a target. I press the submit button and I get not the JSP expected butinstead the same JSP displayed inside its own IFRAME.
    Here is the code for the submit. I've simplified it as much as possible with a static action (originally it was a call to a method) just to try and get things to work. This is the current version:
    <h:commandButton value="View Alias" action="foo" styleClass="select" type="submit" />Here is the navigation rule in faces-config.xml. Again, the problem is that SelectManager get redisplayed in the IFRAME instead of display.jsp.
    <navigation-rule>
       <from-view-id>/SelectManager.jsp</from-view-id>
       <navigation-case>
          <from-outcome>foo</from-outcome>
          <to-view-id>/display.jsp</to-view-id>
       </navigation-case>
    </navigation-rule>I have also tried it without the "from-outcome-value" which I presume means that the "to-view-id" gets displayed unconditionally and it still fails. Any ideas on how I can debug this? (I'm using GlassFish if that's important to know)
    Rob Tanner
    Linfield College

    Raymond, The real trick is avoid doing technical things when coming down with the flu (I should also add that I'm a JSF newbie). Reading your original message this time I see what you're suggesting and found a conversion error although I don't understand it. Here's the code (including the <h:message/>):
                <h:selectOneMenu value="#{members.dcodes}"
                  style="color: #7f0000" id="selector">
                  <f:selectItems value="#{members.departmentList}" />
                </h:selectOneMenu> 
                <h:message for="selector" style="color:white"/>And here's a snippet of the generated HTML:
    <select id="j_id_id26:selector" name="j_id_id26:selector" size="1" style="color: #7f0000">
             <option value="aad" selected="selected">Academic Advising</option>
         <option value="aaf">Academic Affairs</option>
         <option value="adm">Admission</option>
         <option value="up">Upward Bound</option>
    </select>If I select "Admission" for example, the error I get is:
    Conversion Error setting value 'adm' for 'null Converter'.Since everything is a String value, I don't get the error. Could someone please enlighten me.
    Thanks.

  • Yahoo Webcam and WRT54G v5 anyone having disconnect problems?

    Hi all..i have the WRT54G v5 router hooked up to my cable modem.
    When ever i use my web cam it will stay connected for a little bit but then just disconnect and reconnect and its not only on one computer it happens to another computer hooked up....one is wired one is wireless....i have added the port trigger in the router for yahoo's ports inbound and outbound 5100 and it still does it,,,,my next step to eliminate that its the router doing it is to just have one computer running off the modem itself and try it i will do that soon but what i was wondering is if anyone else has had this problem or is having this problem rite now and has any suggestions on whats going on?
    Thanks alot guys and gals.

    Hi everyone.. Im just a newbie here.. just got a question as well.. what if im having the opposite problem.. I cant connect to Yahoo Webcam Service..
    I have followed the port trigger and port forward and aeverything else.. but my webcam still doesnt wanna broadcast.. I know the webcam is working fine..
    I believe the problem started occuring when i started using terminal services, I tried logging on to my pc remotely (from work) and ever since then webcam broadcast just doesnt wanna connect..
    all the help is greatly appreciated...

  • Having a problem with my ipad... I tried to install ios and the ipad has frozen

    I am having a problem with my Ipad air.  tried to install ios and my ipad has frozen

    Click here and follow the instructions.
    (124611)

  • Having a problem with commandButton attribute when i am using it under tabl

    Having a problem with {color:#800000}commandButton {color}{color:#339966}attribute {color}when i am using it under{color:#ff0000} table{color}
    I am using a command button under a table.
    here is the example
    <h:dataTable value="#{wlmHandler.plexes.plexes}" var="{color:#ff0000}onePlex{color}" border="0" cellspacing="0" cellpadding="0" width="100%" border="0">
    <h:column>
    <h:panelGrid border="0" cellpadding="0" cellspacing="0" columns="5">
    <h:commandButton action="" styleClass="tixbutton" value="#{labels.ADD}" onclick="#{onePlex.tran}"/>
    <f:verbatim> </f:verbatim>
    <h:commandButton action="#{createTransaction.transactionCommand}" styleClass="tixbutton"
    value="#{labels.SUBMIT}" actionListener="#{createTransaction.processAction}">
    <f:attribute name="dbName" value="#{wlmHandler.dbName}"/>
    <f:attribute name="plexName" value="{color:#ff9900}#{onePlex.name}"{color}/>
    </h:commandButton>
    </h:panelGrid>
    <h:/column>
    </h:dataTable >
    when i am using this plex name atribute it is giving nullPointerException
    {color:#ff9900}this value #{onePlex.name} i cant able to access inside the command button{color}

    balu i have tried by seeing u r blog.
    this is my structure of tables
    plexes (if i iterate plexes table gives plex object)
    |
    ------ plex (plex table gives transaction object)
    |
    ------transactions(transactions table gives transaction table)
    |
    here i will have a command link to this link i have to pass the plex name which
    will come from
    i tried in this command action with HTMLDataTable getRowData()
    i am not getting the selected row data .i am downcasting this getRowData() to plex.

  • Having a problem with Firefox using Hotmail email. Inbox - as checking messages it freezes up or a 1 item window follows cursor and does not allow you to enter

    I am having a problem accessing Hotmail email messages via Fireflox server. When I am in the Inbox, reviewing messages, it either freezes up or a "1 item" small icon window follows cursor and does not allow me to enter messages or do anything. Have to log off and start over. Suggestions>?

    Can you detect any pattern to it, whether related to messages with attachments, or particular advertising on the page, etc.?
    When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    1. Clear Firefox's Cache
    orange Firefox button ''or'' Tools menu > Options > Advanced
    On the Network mini-tab > Offline Storage : "Clear Now"
    2. If needed, delete the site's cookies here
    While viewing a page on the site, right-click and choose View Page Info > Security > "View Cookies"
    (Usually the dialog will refer to live.com rather than hotmail.com, that's normal.)
    Then try reloading the page and logging in again. Does that help?

  • Anyone else having a Problem with Leopard and Photoshop CS3?

    I'm using CS3 with Leopard 10.5.4 at work and there are some very aggravating anomalies, that I'd like to nail down to a cause. Most frequently, when switching from apps to P'Shop, the menu bar stays for the previous app, i.e. when going from Finder to P'shop, the menu bar still says Finder and has Finder options. Changing from Lightwave to P'Shop, the menu bar remains Lightwave.
    Occasionally, an Adobe app - P'Shop or InDesign - will simply disappear and not come back. The icon in the dock shows it as active, but no amount of clicking, Command-Tabbing will reveal the app and I have to Force Quit, losing unsaved changes.
    I have a feeling it's Leopard, since, I've used CS3 on Tiger and CS4 on Tiger and never had a problem.
    I'm wondering if upgrading to the latest Leopard would make much of a difference.
    Has anyone come across this and found any kind of answers?
    Thanks for any suggestions.
    -Vincent

    > Just because it doesn't happen to Phil (who may not use all of the same features of the Suite that others do anyway) does NOT mean that these problems are not real and are not mere PEBCAK.
    Right. If someone is having a problem associated with Tiger, it's PEBAK. If Leopard is involved, it's automatically because of Leopard. Apparently, with Apple's latest OS, trouble shooting problems are no longer necessary - just blame it on Leopard and call it a day.
    b FUD
    I find the dynamics here really interesting. This thread would have been very different if Vincent had posted with problems involving Tiger. Would have gone something like this:
    After admonishing him for not providing more information about his setup by posting the obnoxious big blue link on how to ask questions (ahem - we know NOTHING about his machine or configuration, such as which machine, how much RAM, scratch disk or attached peripherals), there'd be all kinds of trouble shooting advice given - "try a new user", "repair permissions", "run DiskWarrior, and on and on ...
    But no, since he mentions Leopard, none of that is apparently necessary and the completely, utterly
    b irresponsible
    advice is given ... "that's just the way Leopard is".
    Those are some serious problems he's reporting that have nothing to do with Leopard. Something is obviously hosed!
    As for discounting my experience because I don't use every app in the suite as extensively as I do Photoshop, I'm FAR more qualified to discuss Leopard and CS issues than Ann or Neil who do not use Leopard at all (and have never used it as far as I know.)
    "Others have problems with it", is their battle cry but it's extremely weak. Do I really need to remind you all that these forum are ALWAYS filled with people who have problems, regardless of version or OS? You act as if this forum was a ghost town when Tiger and CS3 were current!
    Gee, Ann ... people are STILL reporting problems with 10.5 and CS3? How shocking! Guess what - people are STILL reporting problems with 10.4 and CS3 too! Let me make a prediction - people will have problems with 10.8 and CS9!
    Vincent-
    > I don't really deal with fonts anyway ...
    Yes. You do. Even if you never type a single line of text, every application uses fonts to create menus and other GUI items. If one of those fonts are bad, it can create all kinds of problems, including the very problems you mention.
    The fact that you don't seem aware of this and you're still using 10.5.4 leads me to believe you're not familiar with the basic practices of maintaining a healthy system. Again, how did you install Leopard on that machine?
    Look, if you're simply trying to justify using CS4, go right ahead. It's a worthwhile upgrade in it's own right. However, if you install it on that machine in it's current state, CS4 will NOT fix your problems because you do NOT have a healthy system.
    You asked for experiences with Leopard - I can launch every application in both CS3 and CS4 suites
    i simultaneously,
    and STILL not have your issues. I haven't experienced anything like your CS3 problems in Leopard - on both a 2006 Mac Pro and a 2008 Macbook.
    If you'd like help to try and figure out the real problem, I'm more than happy to help. If not, Adobe will gladly take your money ...
    -phil

Maybe you are looking for

  • Mapping the IFS from a Windows 2003 service

    Hi, We are trying to install Esker inbound faxing. The process involves their software receiving a file to a Windows server and transfering the file directily to the IFS using a service. My question is how do you get the service user mapping to be av

  • Delete old users/jobs in sm37

    We have some old jobs created in SM37 (R/3 4.7) Some of the people who created the jobs has now left the company. How do I assign the jobs to a another user so we get rid of old names in jobs "created by" column in sm37.

  • Flash CS3 9.0.124 Players update not working

    I downloaded and followed the instruction for updating the players for Flash CS3 so that it publishes 9.0.124 flavours: http://www.adobe.com/go/kb403415 However, when tracing out the Capabilities.version from within the Flash IDE (control+enter) it s

  • How do I permanently get rid of the dummy call forwarding icon on my iPhone 5? I have done a reboot and reset  and even an apple techy in the shop did not have a clue.

    Each time my iPhone comes on the call forwarding icon appears, without operating this function. Have been into the Covent Garden shop where we did a reboot and reset and that appeared to fix it, for a couple of days. Now its back, any ideas anyone?

  • Compound Path to Shape

    I have a questions about creating a single shape from a compound path. I have a grid of lines I created using the pen tool, made the stroke 25pt, then went Object-Path- Outline Stroke to make them into shapes. From there I used the pathfinder-Unite t