Two questions: Scanner and exception handlers

Extreme Newbie Alert: I took a single college semester involving Java, almost five years ago, and haven't really touched it since until recently when I decided to try to get back into it. I am now working on building a program while reading the Java 5.0 Tutorial downloadable from Sun.
Okay, now that the faint of heart have left us, here are the two questions I want to ask:
1) I am trying to use the Scanner tool ( http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html ) on a FileReader wrapped in a BufferedReader. I have installed JDK 5.0 and I am importing java.util.*, but when I try to compile I get this error:
Wishlist.java:71: cannot resolve symbol
symbol : class Scanner
location: class Wishlist
Scanner readFromMe = new Scanner(new BufferedReader(new FileReader("wishlist.txt")));
^
...and then another one pointing to the other appearance of "Scanner" in the same line, followed by six more in places where I use the readFromMe variable that line was supposed to declare and initialize. Any idea why the compiler doesn't recognize Scanner even though I'm importing its package?
2) Is there anything preventing you from nesting exception handlers? As you've seen, in this program I open a file...if that attempt produces a FileNotFoundException, I want the error handling to create a new, empty file to use in place of the one that should have been there. Since this could throw an IOException of its own, I would need to put a try | catch block into the other catch block. Is the compiler going to stand for that? Alternatively, is there any input stream that creates a file with the specified filename if there is none already? Probably not, since a newly created file will be empty and there's no point in having an input stream on it...

1) Are you sure you installed and are invoking jdk
1.5? Maybe you have an earlier version ahead of it
on your path.Hm. I did use 1.3 back in college...I checked the contents of PATH and the User Variables version of it was set correctly but the System Variables version of it was set to 1.3. I corrected the System Variables version of it and now the compiler doesn't complain about Scanner...but I'm still getting errors that it doesn't recognize readFromMe even after I initialized it. Odd...
2) yeah you can nest try/catch blocks like that.
However, in this case, exceptions sound like the
wrong way to go. A missing file sounds like a real,
regular possibility -- it's not that exceptional as
you describe it. A better thing would be to create
a File object, see if the file exists, and then if
it doesn't go ahead and immediately handle that
case. Don't even try to open the file that may not
exist.Okay, I'll try rewriting the file read like that, and hopefully the readFromMe errors will go away. If they don't I'll make a new post...probably with the entirety of the code because I can't even guess at what part of the code is causing that. Thanks for the help!

Similar Messages

  • Two Questions: Link and call transaction

    Hello,
        Im using tableView and tableviewcontrol to display the data and corresponding columns.
        How can I mark one column of table (let say VBELN) as link <a href....> so that user see there is event attached to column. Only one column should have link.
        Secondly, when user click on order, I need to call VA03 and display order. When users see order and and say Back, flow come back to BSP. Will call transaction VA03 in BSP event will work and how? Currently my URL is crashing on VA03.
        Im trying to do something like interactive report.
      Please let me know.
      Ajay

    It sounds like you will want to do a little research on two different topics.  First for your tableView - read up on on tableView Iterators.  There are weblogs and on-line help on the subject. This will allow you to easily control the rendering of individual cells of your table.  You can then render an htmlb:link in the cell in question.
    You can't just call VA03 from a BSP application, VA03 needs to run within the SAPGui. When I have had requirements like this, I like to use the ITS (integrated into the kernel as of Netweaver 04).  The ITS has a service called webgui that will render an HTML version of any SAPGui transaction.  You can pass initialization parameters to the start of the transaction (such as sales order number for the start of VA03).  That way you can jump from your application right into the order you want to view.

  • Two questions, DiskWarrior, and G5 wont sleep...

    Thought I'd make an attempt at gaining two answers here
    Firstly, recently my G5 will not go to sleep using the Energy Saver feature. The screen does go black, but both the little lights, on the monitor and G5 itself don't pulsate and I can hear the machine hasn't goning to sleep. If I however manually click sleep using the power button, it does work fine. I've read through older posts, and tried deleting two of the plist files, rebooted but still not working. It's not massivly annoying, but would be nice if it worked.
    Second question, I have recently bought DiskWarrior, and have two internal drives, I also use Superduper for cloning my main drive, Which I have, so I have a copy of DiskWarrior on both drives effectively. As I'm still waiting for the CD to arrive, can I run DW from either drive to repair the other?
    Appreciate anyones help on either subject
    Thanks!
    Phil

    Hi-
    Sleep problem culprits-
    USB devices- any that are other than Apple keybboards and mice.
    File Sharing turned on.
    Fax receiving turned on.
    Internet sharing turned on.
    Solutions-
    Eject USB storage devices.
    Turn off shared/auto wake preferences
    Reset PRAM.
    Reset PMU/SMU
    Resources:
    http://docs.info.apple.com/article.html?artnum=303698
    http://docs.info.apple.com/article.html?artnum=58645
    http://docs.info.apple.com/article.html?artnum=305262
    http://docs.info.apple.com/article.html?artnum=300341
    Having DW installed on both drives is a good move. As long as both drives are bootable, Yes, you can repair one drive booted from the other drive, and vice-versa.
    G4AGP(450)Sawtooth, 2ghz PowerLogix, 2gbRAM, RaptorSATAATA, ATI Radeon 9800   Mac OS X (10.4.8)   Pioneer DVR-109, 23" ACD, Ratoc USB 2.0, QCam Ultra, Nikon Coolscan

  • Two questions: ical and markspace

    !. Is there a delete keystroke for ical tasks/events? There is a keystroke for cut, copy, and paste, but I can't find one for delete.
    2. When I sync my palm with missing sync, events that are not timed on my palm don't show up in ical at all. anyway to fix this?

    The answer to the first question is: your delete key. No kidding. Highlight the event and press the delete or backspace key. Poof!
    As a long-time Missing Sync for Palm OS user, I really don't know what you mean by "events that are not timed on my Palm…" One common definition of an 'untimed event' is a to do item, which is synchronized by the Mark/Space Tasks conduit, not the Events conduit. Are you referring to…
    • an Appointment without a start and end time?
    • a Floating Event?
    • a To Do entry?
    • a Daily Journal entry?
    • or, another event type from a custom Template?
    If you create actual calendar events [appointments] on a Palm handheld or smartphone and them synchronize them with iCal using Mark/Space events—or, for that matter, using iCal if your not a Missing Sync user—you must select a default calendar in iCal into which such events are transfered.
    In iSync, that's controlled by a somewhat clumsy and not so reliable preference in the pane which drops down when the Tungsten icon in the main window of iSync is pressed. The default is to create an Unfiled calendar in iCal. The problem is that with the release of iSync 2, iCal 2 and Mac OS X 10.4, this process does not consistently perform as expected.
    With the Missing Sync, you choose an existing calendar by double-clicking the Mark/Space Events conduit, and selecting the calendar from a drop-down in the lower right corner of the dialog box. The menu is labeled Put items from read-only calendars into:
    Later Palm OS 5 devices have multiple calendar support, so this is generally not an issue for them.

  • Two questions: rainchecks and payments

    1. I was given a raincheck for a laptop that was on sale at a BB that was far from home. Can I go to another BB that is closer to my house to use that raincheck and still get the sale price or do I have to go back to the same BB?
    2. Can I use multiple forms of payment to complete my purchase? Example: An item cost 500 dollars, can I pay 100 in cash, 200 using a debit card, 100 using a gift card, and 100 using a credit card?
    Thank you.

    Hello El_centro89-
    I apologized for the delay in my response, I understand that you have some questions you have about rain checks and I will be happy to address them.
    Rainchecks are given on case by case bases by the store; therefore you will have to return to the store where it was originated to get it honored. You are more than welcome to use the multiply forms of payment, just let the cashier now the payments you are wishing to use beforehand to avoid any mishaps.
    Thank you for taking the time to write your questions to us.
    Cheers,
    Karina|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Two questions - flv and markers

    1. How do I transfer from fce 3.5.1. to a flv? Any free flash encoder will work? I don't have Flash.
    2. The client wants me to send them a flv file with markers showing. How to make markers show?
    Until yesterday I didn't even know what Flash was.. very new this.

    It depends on the Flash encoder, some will work from inside FCE, others will probably need for you to export from FCE and bring the material into their software. Chapter markers will not export from FCE to most Flash encoders, but you might be able to create the chapters in your Flash encoding software. You will need to do a lot more research on this subject on the web and on forums specifically related to working with Flash. You might try the Adobe forms to start. I'm sure there are others.

  • Two questions: UMA and email

    First, I have an 8900 I bought unlocked from Amazon.com.  It apparently doesn't have UMA, because I cannot find the options even though T-Mobile says it's available.  Is there any way to install it or get it working?  I bought it specifically for this function!
    Second, I'd like for it only to receive email when I ask for it.  Right now it gets email all the time, even after I turned off Reconciliation.  How can I turn off email so I can only retrieve it when I want to?
    Solved!
    Go to Solution.

    #1 - Vendor ID 301 Carphone Warehouse Spain/Carphone Warehouse UK/Carphone Warehouse France/Carphone Warehouse NL
    You won't get UMA from Tmobile with that phone, it is impossible.
    #2 - The BlackBerry works differently, RIM pushes your email to your device regardless.
    Gmail is not set to reconcile to your Blackberry (i.e., sent from PC email shows on the BlackBerry), that is a new feature brought about with BIS 3.0
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Two questions: chmod and restore all of mail

    What must I type on the command line to make all files readable by anyone on my time machine external disk?
    I tried chmod 777 /volumes/2 TB
    (2 TB is the name of the drive)
    and how may I restore from a few days ago all my mail, i.e. the application, preferences, and mail boxes (and their contents).   At the moment I can only view them as system admin. i.e. root.
    bc

    If you perform any such commands on your Time Machine volume it is unlikely you will ever be able to restore from it. You will have to use system admin to restore any applications. They may or may not work. You can copy the other documents to your machine in a place like /Users/Shared. Then, as a standard user, you can copy the file to where they need to be. The copy operation will set the ownership. Hopefully it will work. When you are all done, you should erase your Time Machine and start a new one.

  • Two questions facebook and wi-fi

    book is seem to be not as update as i throught. like if i post my status and i see my friends' status from like 8-11 hours ago. so how can i fix it so i can see their recent status update? is the mobile facebook is not sync to the facebook network?
    also will i be charged if i use wi-fi

    Follow the steps below to change the update time frame.
    Open Facebook application
    Select Menu>Settings
    Refresh interval
    Select time frame
    Also, there is no additional charge for Wi-Fi. 

  • TS3297 I'm trying to buy a song and it won't let me it keeps telling me to ask these two questions like what was my first pets name and what was my childhood nickname and I forget I need help please

    I'm trying to buy a song and it won't let me a page keeps popping up telling me to answer these two questions like what was your first pets name and what was your childhood nickname and I forget the answers and it says I will be locked out of my apple id and I don't want that so can u please help me thanks

    If you didn't establish a rescue email address, you will need to call applecare support.  Ask for account security to reset your security questions.  After the advisor is able to verify your identity, they can reset your security questions.
    HTH.
    If you are in the US, the number is 800-275-2273

  • Two questions on SP1 and Vista booting

    Hi all,
    two questions:
    1) did I understand correctly that if I want SP1 on my machine I have to install it manually, as it is not included in the automatic update routines?
    2) my machine failed yesterday, I got a message "Windows failed to start. A recent hardware of software change might be the cause." The only thing I can think of is that before switching it off the previous time, I had inserted a USB hard-drive to copy some files on it. But I had continued working on the machine normally. The other unusual event is that the day before it was very slow booting up, so afer it finished booting up, I restarted it.
    When the system failed to start, I tried the automatic procedures several times, which always ended up with "windows cannot solve the problem automatcally,
    contact your vendor". In the penultimate attempt, I also clicked on an "advanced option tab" and restored the system, but that also did not solve the problem. Then, this morning I switched the machine on again to write down the exact error message I got, and instead, unexpectedly (and rather gladly), the machine started up normally. So, what might have happened? Should I get my machine (which is less than a month old) checked?
    thanks!
    paola

    Yes, theres a chance to have a complete image from the actual state of your operating system including all programs etc....
    There are several solutions:
    1. The Commercial One: http://en.wikipedia.org/wiki/Ghost_(software)
    2. Another commercial one: http://www.acronis.com/homecomputing/products/trueimage/features-cloning.html
    3. The Free one: http://www.ubcd4win.com/
    (but more complicated and you need in all cases a external data storage, there are some tools on this ToolsCD which are free and do almost the same like acronis or ghostimage)
    I guess there are still thousands of cloning programs but I tried to give you the most important and most reliable tools.
    If I were you, I would check the UBCD4Win, burn it to a CD, buy an external HDD, start the UBCD4WIn and clone your drive to the external one. So you can perform incremental backups of your HDD and if something happens, you must only do the whole process like you perform the backup just reverse.
    Hope I could help you..
    Cheers

  • I have two apple ID's but cannot remember the security question answers and the email address is no longer active - how can I access this account

    I have two apple ID's but cannot remember the security question answers and the email address is no longer active - how can I access this account as it seems to be the one my icloud space is attached to.  I haven't backed up my ipad or photos for a while. 

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312
    If you don’t know your security questions, phone Apple (using the number listed here:  http://support.apple.com/kb/HE57  ) and ask for the Account Security Team.
    About 2-step verification of your Apple ID:
    http://support.apple.com/kb/ht5570
    This is also useful:
    http://www.macworld.co.uk/ipad-iphone/news/?newsid=3463233&olo=email

  • Hello, I have two questions on time capsule  I can only have it on my external hd files and free up my internal memory to my mac  I can use an external hard drive, in my case a lacie rugged as shared memory for my two computers

    Hello, I have two questions on time capsule  I can only have it on my external hd files and free up my internal memory to my mac  I can use an external hard drive, in my case a lacie rugged as shared memory for my two computers

    I have a mackbook pro and an iMac if I buy a time capsule 2tb airport, I can use it with time machine and what would be the best way to use it.
    There is no particular setup required for TM.. both computers will create their own backup sparsebundle which is like a virtual disk.. Pondini explains the whole thing if you read the reference I gave you.
    and how to use time capsule airport whit other external hd to use my old lacie airport with the new time capsule
    Up to you.. you can plug the external drive into the TC and enjoy really slow file transfers or you can plug it into your computer and use it as external drive.. which is faster than the TC.. and TM can include it in the backup.
    Again everything is explained in the reference.. you are not reading it.

  • I would like to buy an iPhone for my friend in Iceland.  Two questions: will the phone work with complete utility in Iceland, and if so, what should I do to confirgure it while in the USA so that it can have full utility in Iceland?

    I would like to buy an iPhone for my friend in Iceland.  Two questions: will the phone work with complete utility in Iceland, and if so, what should I do to confirgure it while in the USA so that it can have full utility in Iceland?

    Bad idea. There are no supported iPhone carriers in Iceland, thus some features may or may not work. Further, there will be no warranty or support for a US purchased iPhone in Iceland...your friend will be on their own. If you still want to go down this road, make sure you purchase an officially unlocked iPhone(GSM model) directly from Apple.

  • When i try to download an app and i have entered my password i am asked to add some security questions. I can add two questions and an alternative e-mail address, however it will not let me select the third security question.

    when i try to download an app and i have entered my password i am asked to add three security questions. I can add two questions and an alternative e-mail address, however it will not let me select the third security question.

    Thanks Liam. After the second ap download it asked me three security questions on iTunes and on my MAC it allowed me to set up these with no error on the third question. iPAD 3 now downloads apps fine.
    Apple really need to sort out this issue or provide guidance on this. Two days of the unit not really being fit for purpose - what use is an IPAD without the ability to download aps.
    Also NO Response from Apple via online tech support and it's now been nearly 24 hours - I was told by telephone support I would get a response within 24 hours or less, as also stated in the email response too!??
    It would be good to get a formal response from Apple on this rather than radio silence.

Maybe you are looking for

  • MacPro Startup Stalls-then boots to wrong drive

    Greetings! I am stumped. My trusty MacPro (dual 3ghz-quadcore) has started to exhibit strange behavior on startup. A few days ago the startup was interupted by what I thought sounded like a failing drive (hic-pause-hic), so I did a fresh install of L

  • How do I maintain column formatting when converting from PDF to Excel?

    How do I maintain column formatting when converting from PDF to Excel? All info is no longer on the lines or in the columns they started out being in? Any help would be appreciated.

  • Query on sap locks(ENQUEUE/DEQUEUE)

    Hi All, should the sap locks ENQUEUE/DEQUEUE need to be used  for all the updation/insertion  of records ino the table? Please confirm.Should this locking technique be used even for insertion of records into the table? Regards, Pra.

  • IDOC - add confirmation "AB" line to a schedule agreement

    Hi, I'm looking for an idoc that adds a confirmation "AB" line to a schedule agreement. We have tried several message types - idoc types, but non of our tests could succesfully add a AB line to the confirmation. Has anyone did this already?  Can you

  • IWeb, QTL's  and Autoplay

    Hi This may be a question for the iWeb board (so I have also posted it there). I am using iWeb to create a site using the Blog template. If I put a Quicktime Movie on an 'entry' page, with Autoplay enabled, then clicking the link to that entry on the