How make "Scanner" not printing the output in a new line?

Hi!
I'm Jordi from Barcelona and I'm new on Java and on this Forum. I have a question to you. I'm developing a testing application that uses the "Scanner".
Before using it, the app asks a question to the user:
String strInput;
Scanner sc = new Scanner(System.in);
System.out.print("* Please, write your name: ");
strInput = sc.next();Running this, the app asks me for the options and after pressing "Enter" prints the input string in a new line like this:
* Please, write your name:
Jordi
And I would to get the next:
* Please, write your name: Jordi
Does anybody know how to make the "Scanner" print the output in the same line as the question?
Thanks for your help!
Jordi

Running the code,
import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("* Please, write your name: ");
        System.out.println("* Hi, "+sc.next());
}results in the following output:
* Please, write your name: Bart
* Hi, BartWhere the first "Bart" is the input I gave.
If this is not the case, then it has something to do with your IDE or perhaps you didn't recompile and it previously was
System.out.println("* Please, write your name: "); // println instead of printbut it's all guesses.
Good luck.

Similar Messages

  • How to Call and print the output eBusiness Report

    Hi
    I have gone through all the posted threads to see whether any of the thread solution matches my requirement. But, I couldn't find any.
    I have a report which is registered in eBusiness and I wanted to run the report and wanted to show the report output in APEX.
    How can I achieve this?
    Appreciate your Help.
    Regards
    Kiran Akkiraju

    i have thought a code like below...but its missing...please look at the comment line on the code...i hope i am on the right way...please correct me
    response.reset();
              ServletOutputStream cikti=response.getOutputStream();
              BufferedImage servletResim=new BufferedImage(150,50,BufferedImage.TYPE_INT_RGB);
              Graphics2D graf=(Graphics2D) servletResim.getGraphics();
              graf.     // here i must get the image file from hdd path but how?couldnt find any valid method?
              JPEGImageEncoder enkoder=JPEGCodec.createJPEGEncoder(cikti);
              enkoder.encode(servletResim);
              cikti.close();

  • My printer will not print the web pages using firefox...how do I set it up to print a web page?

    I have an hp photosmart c4180 printer and it will not print the web pages in firefox...how exactly do I set up FF so I can print web pages? I will need step by step instruction also on exactly where to go to set it up.

    Open System Preferences (gear icon on the dock), then open Print & Scan
    Click the + button at the bottom of the printer list
    If your printer appears....not all printers are supported....click on the name to highlight it
    Click the Add button to install the printer at the AirPort Express location
    Try to print. You must choose the correct printer at the AirPort Express location since the printer is "installed" at other locations on your network.
    If you open Print & Scan again, and select the printer at the AirPort Express, there is an option to make the printer the "default" location, so you do not have to choose which location to select when you want to print.

  • How to print the output of the screen in Dialog Programming

    Hi,
    Could anybody help how to print the output of a screen in the dialog programming. i can select 'Hard Copy' option in the 'Custumizing of Local Layout' Icon in the standard tool bar. but that prints the whole screen with the toolbar. i want to print only the output which is displayed on the screen. Please help..
    Regards,
    Swathi

    Hi Swathi,
        Ok. Do One thing. Go to menu bar and select Systems -> Own pool Request -> here you get the spool number. Select it and select the option "Print Directly" in tool bar.
    Thanks.

  • My Canon Pixma MG 7100 makes 2-sided printing the default. How can I change that to 1-sided for defa

    My Canon Pixma MG 7100 makes 2-sided printing the default. How can I change that to 1-sided for defa

    Hi janekieschninck,
    If the printer is currently set to perform duplex (2-sided) printing, you can turn off the setting by deselecting the option in the printer driver. Please follow the instructions at the link below associated with your operating system to find where the duplex feature is located for your operating system:
    Duplex printing - Mac
    Duplex printing - Windows
    Hope this helps!
    This didn't answer your question or issue? Please call or email us using one of the methods on the Contact Us page for further assistance.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • I have a hppsc 1310 series that prints the test page, butr will not print the selected document.

    I have a hppsc 1310 series that prints the test page when turned on, but will not print the document I want to print.  It shows in STATUS as printing, but it does not print.  I keep getting a message to install software and I do this.  I then get a message software installed, but it still will not print.  This just started about five days ago. 

    Hello ausection29,
    Most likely what is printed when you turn on the PSC 1310 is an alignment page. To complete the alignment process you need to place this page on the scanner glass and press the Scan button. The top of the page should be towards the left of the printer I believe, double check this on your printer (there should be a small icon next to the scanner glass showing which way the paper should be placed on the glass).
    You can have a look at step 5 in this document for a video of how to do this:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01577355&cc=us&lc=en&dlc=en&product=374568&tmp_...

  • Err. E:"TRANSPORTING NO FIELDS" will not fill the output area.

    Dear all,
    Below are my codes and i keep getting this error
    E:"TRANSPORTING NO FIELDS" will not fill the output area. The addition does not make sense here.
    Any idea how to fix this?
    The first bit...
    TABLES: /BI0/MWBS_ELEMT.
      DATA:   I_MWBS_ELEMT LIKE /BI0/MWBS_ELEMT OCCURS 0 WITH HEADER LINE.
      DATA:   W_MWBS_ELEMT LIKE LINE OF I_MWBS_ELEMT.
    Then second bit...
      READ TABLE I_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID TRANSPORTING NO FIELDS INTO W_MWBS_ELEMT.
      IF SY-SUBRC IS INITIAL.
        RESULT = W_MWBS_ELEMT-RESP_CCTR.
        RETURNCODE = 0.
      ELSE.
        SELECT SINGLE * FROM /BI0/MWBS_ELEMT INTO W_MWBS_ELEMT
                        WHERE WBS_ELEMT = SOURCE_FIELDS-POSID
                        AND OBJVERS = 'A'.
        IF SY-SUBRC IS INITIAL.
          APPEND W_MWBS_ELEMT TO W_MWBS_ELEMT SORTED BY RESP_CCTR.
         RESULT = W_MWBS_ELEMT-RESP_CCTR.
        ELSE.
          CLEAR RESULT.
        ENDIF.
      ENDIF.

    Hi
    The error is here
    READ TABLE I_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID TRANSPORTING NO FIELDS INTO W_MWBS_ELEMT.
    The addtion TRANSPORTING NO FIELDS is in conflit with addition INTO:
    TRANSPORTING NO FIELDS means not to fill the work are
    INTO mean fill a work area
    So or u need to fill a work area or u don't need to fill a work area, but (from the code you've pasted) it seems u need to fill the work area W_MWBS_ELEMT, so your code should be:
    READ TABLE I_MWBS_ELEMT INTO W_MWBS_ELEMT WITH KEY WBS_ELEMT = SOURCE_FIELDS-POSID.
      IF SY-SUBRC IS INITIAL.
        RESULT = W_MWBS_ELEMT-RESP_CCTR.
        RETURNCODE = 0.
      ELSE.
        SELECT SINGLE * FROM /BI0/MWBS_ELEMT INTO W_MWBS_ELEMT
                        WHERE WBS_ELEMT = SOURCE_FIELDS-POSID
                        AND OBJVERS = 'A'.
        IF SY-SUBRC IS INITIAL.
          APPEND W_MWBS_ELEMT TO W_MWBS_ELEMT SORTED BY RESP_CCTR.
         RESULT = W_MWBS_ELEMT-RESP_CCTR.
        ELSE.
          CLEAR RESULT.
        ENDIF.
      ENDIF.
    Max

  • My printer will not print the body of my emails

    My HP printer will not print the body of my emails.

    Hey hcwooten,
    I see you are having an issue with your printer producing outputs of only the top of the page.  I would like to help, but need a little more information to best assist.
    What model HP printer do you have?
    What is the operating system of the PC you are using to print from?
    How is the HP printer connected to this PC?
    Do you have the full feature software installed on this PC for your printer?
    What program are you printing from?  Does this happen only in specific programs or all programs?
    Have you tried running the HP Print and Scan Doctor?  This is an automated troubleshooting tool that fixes many printing/scanning related issues.  
    HP Print and Scan Doctor
    http://h30434.www3.hp.com/t5/Other-Printing-Questi​ons/Want-Good-Answers-Ask-Good-Questions/td-p/2094
    Jason
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------
    I am not an HP employee.

  • My printer will not print the docs in the que.

    My printer will not print the docs in the que. I think it may be the norton virus protection I Installed recently. How do I fix this?

    If one thing gets held up in que then all other doc's follwing will be held up as well-
    Download and run the "PRINT DIAGNOSTIC UTILITY" to get rid of the things in your print que
    Download it here:
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategor​y?os=4063&lc=en&cc=us&dlc=en&sw_lang=&product=4083​...
    Save it to your Desktop and then run it> Click "Fix" when it comes to your QUE
    Although I work for HP, I am speaking for myself and not for HP.
    Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )

  • Bursting Control file, Error!! Could not deliver the output for Delivery

    Hi,
    I am using bursting control file to send report output to email in R12.1.3.
    If the report output is having data, it is working fine. if there is no data it is getting errored out with the below message.
    "Error!! Could not deliver the output for Delivery channel:null "
    In the report output i put "No data found", when i click on view output the output in application is showing as "NO DATA FOUND" in PDF .
    "Bursting VMC Approved Purchase Orders for a period (XML Publisher Report Bursting Program)" got above error.
    my requirement is if there is no data, still i require the output to email.
    Thanks in Advance
    Adina.

    Hi,
    I am facing the same situation and want the bursting program to finish in normal even when there is no data.
    Can you please let me know how you resolved this?
    Thanks
    RG

  • Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor and premiere it? Working with two cinema display and PN- K321 and I can not preview the output video at 4K for DisplayPort, whereas with premie

    Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor, and premiere yes?
    Working with two cinema display and PN- K321 and I can not preview the output video at 4K by DisplayPort, whereas with premiere and after effects I have no problems

    Look, you can build an HD DVD with an SD movie, just as you can build an SD DVD with an HD movie. This is not a bug, it is most likely user error. Apple will not be addressing it.
    Just start over, and ensure you are building an SD DVD by bringing up the inspector for the disc (click on the background in the Graphical tab).
    Make sure SD DVD is selected:
    (If you do the same thing on your ill fated project, you'll see that HD DVD is selected)
    Build your DVD and you'll be fine.
    Patrick
    P.S. You will need to google HD DVD and Blu-Ray if you want to understand the difference between the formats. The reason that DVDSP included HD DVD was that its format was similar to SD DVD's. Blu-Ray is something else entirely.

  • Problem with ghostscript ['Distiller' did not produce the output file ]

    Hi,
    We are trying to convert the checked in files to pdf using ghostscript.
    The Steps i have followed in installing the Distiller
    First I have installed gs8.64 and configure distiller
    Refinery server--> Conversion settings --> Third-party Application Settings --> Distiller Engine --> options -->
    Use GhostScript and provided the path to install dierctory as C:/Program Files/gs/gs8.64/
    Installed Printer as per the pdf
    Conversion Settings --> Primary web redention --> convert to pdf using third party applications
    Server details:
    CS: 10gr3
    ghost script 8.64
    Plz find the below logs details
    Error Log...
    Copying c:/ucm/server2/vault/~convert/idc/2/2.txt to c:/ucm/server2/vault/~convert/idc/2/temp.ps
    Waiting for exclusive access on c:/ucm/server2/vault/~convert/idc/2/temp.ps
    Obtained exclusive access on c:/ucm/server2/vault/~convert/idc/2/temp.ps
    Waiting on Distiller
    Check for file c:/ucm/server2/vault/~convert/idc/2/temp.pdf failed
    'Distiller' did not produce the output file 'c:/ucm/server2/vault/~convert/idc/2/temp.pdf'.
    Exception type is 'java.lang.Throwable'. Details
    An error has occurred. The stack trace below shows more information.
    !$Copying c:/ucm/server2/vault/~convert/idc/2/2.txt to c:/ucm/server2/vault/~convert/idc/2/temp.ps <br>Waiting for exclusive access on c:/ucm/server2/vault/~convert/idc/2/temp.ps <br>Obtained exclusive access on c:/ucm/server2/vault/~convert/idc/2/temp.ps <br>Waiting on Distiller <br>Check for file c:/ucm/server2/vault/~convert/idc/2/temp.pdf failed <br>'Distiller' did not produce the output file 'c:/ucm/server2/vault/~convert/idc/2/temp.pdf'. <br>!syExceptionType,java.lang.Throwable
    java.lang.Throwable
         at intradoc.common.IdcLogWriter.doMessageAppend(Unknown Source)
         at intradoc.common.Log.addMessage(Unknown Source)
         at intradoc.common.Log.errorEx2(Unknown Source)
         at intradoc.common.Log.errorEx(Unknown Source)
         at docrefinery.agent.Logger.logError(Logger.java:138)
         at docrefinery.convert.StepHandler.executeStepByName(StepHandler.java:140)
         at docrefinery.convert.ConversionDriver.processSteps(ConversionDriver.java:231)
         at docrefinery.convert.ConversionDriver.convertDocument(ConversionDriver.java:144)
         at docrefinery.convert.ConversionDriver.processSubConversion(ConversionDriver.java:165)
         at docrefinery.convert.StepHandler.executeStepByName(StepHandler.java:109)
         at docrefinery.convert.ConversionDriver.processSteps(ConversionDriver.java:231)
         at docrefinery.convert.ConversionDriver.convertDocument(ConversionDriver.java:144)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor.handleCurrentQueueItem(PreConvertedRefineryQueueMonitor.java:204)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor.monitorRefineryPreConverterQueue(PreConvertedRefineryQueueMonitor.java:125)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor$1.run(PreConvertedRefineryQueueMonitor.java:93)
         at java.lang.Thread.run(Thread.java:595)
    Conversion completed -- Step PostscriptToPDF forced conversion failure by conversion engine because of error: ''Distiller' did not produce the output file 'c:/ucm/server2/vault/~convert/idc/8/temp.pdf'.'. Exception type is 'java.lang.Throwable'.
    Please suggest me where i am going wrong...
    Thanks in advance,
    Prasad V.

    Hi Srinath,
    Thanks for your reply. It worked fine with 8.63 version.
    Is there any other way to get it worked with out installing ghostscript.exe as the client doesnt want to instal any exe file on the server as it has broader impact on other instances also, can we acheive the conversion by copying the extracted zip files of ghostscript-8.63.tar.gz .....
    We tried with extracted zip files by following the below settings
    Refinery server--> Conversion settings --> Third-party Application Settings --> Distiller Engine --> options -->
    deselected Use GhostScript and provided the Path to generic PostScript to PDF engine D:\ghostscript\ghostscript\lib\ps2pdf14.bat
    Parameters to pass to generic PostScript to PDF engine.
    <$postscriptFile$> <$pdfFile$>
    Path to generic PDF optimization engine.
    D:\ghostscript\ghostscript\lib\pdfopt.bat
    Parameters to pass to generic PDF optimization engine.
    <$pdfFile$> <$optimizedPdfFile$>
    Installed Printer as per the pdf
    Conversion Settings --> Primary web redention --> convert to pdf using third party applications
    We are getting the below error:
    Waiting for exclusive access on c:/temp/idcoutput.ps
    Obtained exclusive access on c:/temp/idcoutput.ps
    Waiting on Distiller
    Error Distilling
    Exception type is 'java.lang.Throwable'. [ Details ]
    An error has occurred. The stack trace below shows more information.
    !$Waiting for exclusive access on c:/temp/idcoutput.ps <br>Obtained exclusive access on c:/temp/idcoutput.ps <br>Waiting on Distiller <br>Error Distilling <br>!syExceptionType,java.lang.Throwable
    java.lang.Throwable
         at intradoc.common.IdcLogWriter.doMessageAppend(Unknown Source)
         at intradoc.common.Log.addMessage(Unknown Source)
         at intradoc.common.Log.errorEx2(Unknown Source)
         at intradoc.common.Log.errorEx(Unknown Source)
         at docrefinery.agent.Logger.logError(Logger.java:138)
         at docrefinery.convert.StepHandler.executeStepByName(StepHandler.java:140)
         at docrefinery.convert.ConversionDriver.processSteps(ConversionDriver.java:231)
         at docrefinery.convert.ConversionDriver.convertDocument(ConversionDriver.java:144)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor.handleCurrentQueueItem(PreConvertedRefineryQueueMonitor.java:204)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor.monitorRefineryPreConverterQueue(PreConvertedRefineryQueueMonitor.java:125)
         at docrefinery.queue.PreConvertedRefineryQueueMonitor$1.run(PreConvertedRefineryQueueMonitor.java:93)
         at java.lang.Thread.run(Thread.java:595)
    Conversion completed -- Step PostscriptToPDF forced conversion failure by conversion engine because of error: 'Error Distilling'. Exception type is 'java.lang.Throwable'.
    Plz let us know if it is possible to convert the docs to pdf with out installing the ghostscript.exe file on server.
    Thanks in advance,
    Prasad V.

  • Runtime.getRuntime().exec hangs and doesn't print the output

    Hi,
    I have written the following code to execute the command "psexec ipaddress -u userid -p password -l -c execute.exe >> c:/25_showoutpout.txt" and print the output in 25_showoutpout.txt file.
    import java.io.*;
    public class ExecTest{
         public static void main(String args[]) throws IOException{
         String args1 = "psexec ipaddress -u userid -p password -l -c execute.exe >> c:/25_showoutpout.txt";
         try{
         Process p=Runtime.getRuntime().exec(args1);
    int i = p.waitFor();
         System.out.println("Done.with time "+i);
         }catch(Exception e){
              System.out.println("The error is "+e);
    But this program hangs and creates a blank 25_showoutpout.txt file.In the process list I can see the process running, but it doesn't redirect the output in the txt file.When i run the command from the command line it runs fine.Please help me.
    Thanks in advance

    Hi,
    I have written the following program to get the output.But still the required output is not coming in the console file.Only the messages that gets printed in the parent console that is coming in the file.But the expected output is to get the messages from the child window which gets executed while the .exe runs.
    import java.io.*;
    public class RuntimeExecTest{
    public static void main(String args[]){
    String s = null;
    String result= null;
    int count =0;
    try{
              // read the output from the command
    String cmd = "cmd.exe /c D:/installer/PsTools.zip/PsTools/psexec.exe ipaddress -u userid -p password -l -c excute.exe >> C:/RuntimeExec_25.txt";
         Process p = Runtime.getRuntime().exec(cmd);
         InputStream is = p.getInputStream();
         // Get the std in to the process.
         OutputStream os = p.getOutputStream();
         // Get the std err from the process.
         InputStream es = p.getErrorStream();
         // Create readers for those streams.
         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
         BufferedReader errReader = new BufferedReader(new InputStreamReader(es));
         String line;               
         // Read STDOUT into a buffer.
         // If no STDOUT check STDERR.
         while((line = errReader.readLine()) != null){
              // Do something with data here if you wish.
         System.out.println( line );
         while((line = reader.readLine()) != null){
              // Do something with data here if you wish.
         System.out.println( line );
         System.exit(0);
    catch( Exception ex )
    ex.printStackTrace();
    }

  • Form will not print the typed information?

    My forms will not print the typed information only the form itself as a blank form.
    I have Acrobate 8 Professional V. 8.3.1
    Please advise on how to correct this annoying problem that started with the latest update.
    Thanks

    For Macintosh the AdobeViewer Plugins does not function and Hasn't since Acrobat 8. Adobe has no intention of fixing  it, I received a nasty reply:  what feature do you want removed in order fix the problem.  Its not worth it and we have no intention of ever fixing it. However its shipped and installed on the Mac version
    The only PDF Plugin that works  is PDFBrowser Plugin by Schubert of Germany, and it appears he has discontined updating although Thankfully It works in OSX.8  with most mdern Updates.  You can Only fill out forms by opening Chrome, iCab , and OperaNext only Safari doesn't work and any product using the Gecko Rendering engine (Mozilla Products , FireFox and SeaMonkey  Form Fields don't work or crash the browser. (depending upon version of the pdfBrowser Plugin).

  • Getting Error!! Could not deliver the output for Delivery channel:null

    Hi All,
    I have an XML Bursting program wherein I have given the output type as pdf.
    But as soon as I change the output type to Excel, I get the error - Error!! Could not deliver the output for Delivery channel:null
    Can anyone please advise me what could be the possible reason for this Error and how can I resolve the same.
    Regards,
    Shruti

    Hi,
    I am facing the same situation and want the bursting program to finish in normal even when there is no data.
    Can you please let me know how you resolved this?
    Thanks
    RG

Maybe you are looking for

  • Change encoding of input message sent by J2EE Adapter

    Hi all, I get a input message with a wrong encoding (Sender SMTP Adapter). Within XML prolog, there's a declaration of UTF-8. Having a look at the message, it's ISO-8859-1 encoded. That mean's I've to do one of the following options: a) change encodi

  • Errors in the OLAP storage engine: A duplicate attribute key has been found when processing

    Hi dear MSDN Community, I am facing a problem while processing a cube with a customer hierarchy as follows: Global Account --> Main Customer --> Master Customer --> Customer The data comes from a flatted parent child table, that is, I create an extra

  • Gnome Network Manager Isues

    Hi Guys, I have some weird issues with Gnome Network manager when I first boot up. I seem to have 2 profiles for my network connection enp3s0. I have a static IP for my PC, xxx.xxx.xxx.66, as I share music and photo's with a media centre PC in anothe

  • Not allowing me to move my files to trash?

    Title pretty much sums it up, whenever I hit the delete the key on a file (even files and folders in my own home directory) It says "Cannot move file to trash.." ANY File.  I go to trash, its empty. Is there some obscure Trash group that I completly

  • Lost Photoshop package in a house move

    Ive managed to lose my Photoshop software. I know the registration details but struggling after that. Is there anything I can do?