How do i get something from keyboard into primitive data type such as int

Hi guys,
How do i store a value that was accepted via keyboard into a int variable.
The method i tried to use was readInt of DataInputStream class which allows me enter some number then enter some number again and when i print the value stored in the variable, which is suppose to be what i entered, it prints a junk number.

import java.io.*;
public class Read {
     public static void main( String [] args ) throws Exception {
          BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
          System.out.print( "Integer: " );
          String integer = br.readLine();
          int i = Integer.parseInt( integer );
          System.out.println( "i = " + i );
          br.close();
}

Similar Messages

  • How do I get pics from Preview into iphoto?

    How do I get pics from Preview into iphoto?

    While you are viewing a photo in Preview, and want to import it into iPhoto, select the document icon in the toolbar of the preview window and drag this icon onto the iPhoto icon in the Dock or in the applications folder.
    For example:

  • How do I get images from Aperture into print shop for mac?

    Friends,
    I have Print Shop for Mac and Aperture. How do I get images from Aperture into Print Shop? I'musing managed images with previews. Is there any option besides exporting to the desktop and importing?
    Thanks!
    Steve

    if you have previews turned on in Aperture and they're all genereated, you can simply drag-n-drop them into any application (just about). drag-n-drop is essentially the same as copy/paste as long as the application is setup to accept "drops" onto its windows.
    otherwise, if you're running Leopard (10.5) as your version of Mac OS X, when you import (or whatever it is in PrintShop), you should get a file selection dialog. from here, scroll down the left-hand side bar set of icons. near the bottom is a group called "Media". click on the triangle to open the group, choose Photos, and from here you should see an Aperture icon. click this and you'll see your whole library (or at least the portion of it that you have previews generated for. select the photo you want and viola!
    scott

  • How do i get something from the Input ( Keyboard ) - NOT an Applet

    something simple for u guys...im nea @ this...so which methods do i need to get something from the keyboard...i mean..console waits for you to write a line ( a String ) and after pressing Enter the program puts it in another String in my code...
    hope u get what im talking about...sorry for the bad english...thnx a lot!!!! :)

    this class has how to get from a file or from a String in your code but cant find something like get the String from the console ( like u do in C language ).
    here is the scan class : here

  • How do you store input from keyboard into a string array

    I am trying to learn java and one of the programs I am trying to write needs to be able to accept a machine hostname at the keyboard and stuff it into a string array element. I am sure I will be using something along the lines of:
    BufferedReader in = new BufferedReader(new InputStreamReader(
                             System.in));
                   String str = "";
                   System.out.print("Enter a FQDN to look up: ");
                   str = in.readLine();
    but how do I get the input stuffed into hostname[ ].
    Any hints or assistance will be appreciated.
    Michael

    Well part of. I need to be able to take a random number of hostnames (ie. mblack.mkblack.com, fred.mblack.com, joe.mblack.com, ...) and after the user presses the enter key between each entry, the inputted information is stored in an array element. for example with the three shown above the array would look like this after the user finished.
    hostname {"mblack.mblack.com","fred.mblack.com","joe.mblack.com"};
    the algorithm would be
    Prompt for hostname
    get user input and press enter
    store hostname into array element
    prompt for next hostname or enter with no input to complete entry and execute lookup.class methods.
    I have the program written and working fine if I use a static array where I put the hostnames in the list, but cannot figure out how to get the information from the keyboard to the array element.
    Thanks for the help though, the response is very much appreciated.
    Michael

  • How do I get music from itunes into my slideshow in elements 10

    What is the procedure to get music from itunes into a slideshow in elements 10?

    If your music is in iTunes own format, you'll need to convert it first. Elements works best with .wav files. Here is the Apple article on making conversions:
    iTunes: How to convert a song to a different file format.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • How can I read something from keyboard using i/o operations?

    I wrote the following code in java using *"oracle Jdeveloper 11g release 2"* platform and i think it's correct, but I have a little problem when I try to execute him, it asks me to introduce a number, and this it's correct, but I don't know how to introduce that number. If i want to write the same code in c or c++ using Visual Studio it's very easy when i want to introduce a number i must run the code and then a console window will appear and then i introduce the number.
    Could someone to give me a link at a tutorial about how to use *"oracle Jdeveloper 11g release 2"* when I have to use i/o operations or something useful.
    package instante;
    import java.io.*;
    public class Read_from_keyboard {
    public static void main(String[] args) {
    BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in), 1);
    double number_read = 0.0;
    String line = "";
    try {
    System.out.flush();
    System.out.println("Give a number: ");
    line = keyboard.readLine();
    Double tmpDouble = Double.valueOf(line);
    number_read = tmpDouble.doubleValue();
    System.out.println("The number is: " + number_read);
    } catch (IOException e) {
    System.out.println(" Input from keyboard " + e.toString());
    System.exit(1);
    Thank you!
    Edited by: Iosif on Nov 9, 2012 5:06 AM

    Its a command line application. Perhaps JDeveloper has support built in to be able to do that in the IDE, but generally you'd just want to run a command line application on the command line / shell. How to do that is described in any Java book, in the Oracle Java tutorials and in just about a couple hundred/thousand articles you can find through Google.
    Other than that, the JDeveloper forum is here:
    JDeveloper and ADF

  • How do I put something from iPhoto into iCloud?

    I'm trying to put photos from iPhoto into iCloud and am not sure how to access iCloud?

    If you have OS X 10.7.5 or higher and iPhoto 9.2.2 or higher, go to System Preferences>iCloud, sign into your iCloud account, check Photos and click Options and enable My Photo Stream.  Then in iPhoto, select the photos you want to add to photo stream, then do any of the following:
    Click the Share button in the toolbar, click iCloud, and click My Photo Stream.
    Click the Add To button in the toolbar, click iCloud, and click My Photo Stream
    Drag the photos to iCloud in the Source list, and click My Photo Stream.
    Choose Share > iCloud, and click My Photo Stream.
    If you don't have OS X 10.7.5 or higher and iPhoto 9.2.2 or higher you'll have to upgrade first.

  • How do I get pictures from mail into iPhoto

    I am using Mail 6.6 with Mountain Lion on a Macbook Pro. Mail with Snow Leopard has a drop down menu to: a) save all or b) save to iPhoto.
    Mail 6.6 does not provide the option to save a picture to iPhoto. How do I get it there?

    Welcome to Apple Support Communities
    When I right-click (Command+click) on an attached image in Mail 6,6, with Mountain Lion OS X 10.8.5, I have the option to open the program in a number of registered applications (I have Parallels and Win 7 installed, so a number of registered Windows apps are cluttering my list). iPhoto is not immediately listed, but...
    Click 'Other ...' at the bottom of the list, and iPhoto is right there in the Applications folder listing.
    Since I used iPhoto already today, it's near the top of Today list, as illustrated:
    Clicking iPhoto.app opens the image in iPhoto and automatically imports it as shown:
    Alternately, you can save several images to your Downloads folder or other folder location you select and then import them into iPhoto as a batch later.

  • How can I get songs from iPhone into iTunes

    okay so on my old computer (and on my iphone now) i had/have around 1000 songs in my itunes from various websites, around half of these are free downloads of independant artists and things like that, so not purchased in itunes. the other half i did purchase. my old computer broke, so i can't get to any of the non purchased songs, besides from my phone. i transferred all my purchases into my new computers itunes so around 450 of my songs i can access, but the rest are only on my phone. itunes keeps prompting me to erase and sync but that would get rid of all the non purchased songs on my phone so they would basically be lost forever, right? i know they want me to do that to protect against illegal downloads and things like that but this stuff isn't downloaded illegally! is there anything i can do to get my music on this computer or am i basically screwed? also i've tried downloading a few free tracks from various websites (again, legally)... they are showing up in my itunes library but every time i try to drag them onto my phone it doesn't work. my computer is authorized and i've tried everyhting else i can think of... can anyone help? i have windows 8 and my itunes and iOS are both updated fully, if that makes any difference. thanks!

    The iphone//ipad/ipod is not a backup/storage device.  The sync is one way - computer to iphone.  The exception is itunes purchases.
    There is no free, or Apple supported,  way to extract any other music.
    It has always been very basic to always maintain a backup copy of your computer.  Use your backup copy of your computer to put everything back.
    Iphone sync with one computer at a time.  Syncing to another will erase the current content from the iphone and replace with the content of the new computer.

  • How do I get documents from iCloud into iPad?

    I can't figure out how to get Page documents that I moved from iMac to iCloud to sync with iPad.

    Settings app > Pages > Use iCloud (turn it ON)
    Also check to see that iCloud is turned on in general for the phone and that you are signed in (Settings App > iCloud)

  • How to I get photos from iPad into LR mobile

    CCan I bring photos from the photo section of iPad into LR mobile, on same iPad ? Thanks

    In the Collections View, tap the "+" in the upper right to create a new empty collection.  Tap the Add from Camera Roll in the middle of the empty collection. Select the Album from the top pull down. Add as many photos as you like to your Lightroom mobile collection. (Note: These will sync back to your Desktop). Hit the Check Mark (upper right) and you are done.
    If you Long Press on a photo it will give you options for selecting multiple photos.

  • How can I get photos from imovie into iphoto?

    I downloaded the photos onto my desktop and made an imovie with the photos...but at some point I deleted the photos file AND I lost the original photo cd they were on.  The photos are in my imovie file, but I need to somehow get them to iphoto (or somewhere) to burn onto a cd.  This was I can print out just the photos.  ANY help would be greatly appreciated!

    What version of iPhoto? Is OS X 10.2.x as you state correct for your OS?
    LN

  • How do I get my bluetooth keyboard to print or type again?

    My 27" iMac from 2011 froze and nothing initially seemed to reactivate it but after some guidance it turned out my bluetooth keyboard batteries were shot and some of the start-up tricks weren't working with a full deck but after a while we had movement on the arrow pointer and all seemed right with the world.  Then today my keyboard seemed to stop its function and I can't type anything. Any suggestions?

    SMC reset - Intel-based Macs: Resetting the System Management Controller (SMC)
    PRAM reset - OS X Mavericks: Reset your computer’s PRAM
    Barry

  • How do i get the nearest upper limit for Date types?

    DB Version: 10gR2
    SQL> alter SESSION set nls_Date_Format = 'DD-MM-YYYY HH24:MI:SS';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    22-10-2010 13:20:35After applying the function i should get
    SYSDATE
    22-10-2010 14:00:00

    Hi,
    You can use TRUNC to round a DATE down to the preceding minute, hours, day, week, ...
    TRUNC only rounds down. If you want to round up, you can add almost one hour to the DATE, and then round down:
    TRUNC ( SYSDATE + INTERVAL '3599' SECOND
          , 'HH'
          )If you add exactly 1 hour, then, if SYSDATE happens to be, say, exactly 04:00, then you would get 05:00 returned.
    Edited by: Frank Kulash on Oct 21, 2010 3:16 PM
    I just saw HM's solution; it's probably easier to read and understand.
    I think HM made a typo; you want to add 1 hour before TRUNCating, not 1 day, so say:
    decode(sysdate,trunc(sysdate,'HH24'),sysdate,trunc(sysdate+ (1 / 24),'HH24'))
    --                                                          ********  <= Very important!

Maybe you are looking for

  • Problem with installation application server 10g on Solaris 10 sparc

    Hello all. Help me, please. I'm trying to install Oracle aplication server 10.0.1.2.0.2 on Solaris 10 sparc. Server - Sun Fire v210. When i install oracle infrastructure(metadata repository and identify management), i have a problem - on first step o

  • Earlier attachment opens in Mail

    When using Mail, opening attachments named the same as earlier attachments, the programme opens the earlier attachments instead of the one sent to me. Is there somewhere I can change this? MacBook Air OS 10.8.2 Mail 6.1 (1498)

  • ITunes 11.4.0.18 update erased previous library

    After updating to iTunes 11.4.0.18 for use with my iPod Touch, 4th gen. iOS 6.1.6, my previous library complete disappeared.  I'm working with Windows 7 on a machine that more than meets the hardware specs for this particularly software. The problem:

  • Can not print song lists for jewel case with windows

    I have PC with Windows 7 and have downloaded the latest version of I Tunes and still can not print out a list of songs that will fit into a jewel case.  The songs print all over one another in a garbled mess.  Any suggestions on how to fix this?  I h

  • Oracle Business Rules :  File Type Rules Repository Creation Problem

    Hi Gurus, I am trying to create File Type Rules Repository(SOA Suite 10.1.3.3). As per the documentation:user Guide Oracle Business Rules supplies a blank file repository that does not contain a dictionary. This file repository is named "emptyFileRep