System.out.print and System.out.println

is it true that the System.out.print("\n") will print a new line character in all platforms?
in other words is it ok to assume that System.out.print("\n") and System.out.println(); will give the same output regardless of platform?

System.out.print("\n") Chances are that will produce different results on different platforms as some platforms use \n, some use \r some use \n\r (or is it \r\n?).
The question is why do you care when System.out.println() will do what you want? An alternative:
System.out.print(System.getProperty("line.separator"));

Similar Messages

  • Difference between " system.out.print( ) " and " system.out.println( ) "?

    Hi frnds, i m a beginner in JAVA today only started with the complete refrence....can you help me and tell the the Difference between " system.out.print( ) " and " system.out.println( ) "?

    Rashid2753 wrote:
    hi,Yes. But it's a good idea for new Java programmers to become accustomed to using helpful resources like the API Javadocs because it's much faster then waiting for replies everytime you have a question. For experienced developers the API Javadocs are an indispensible resource.

  • System.in.read and System.out.print questions

    On the following code, two questions:
    1. the output is not what I expected. Why doesn't the System.out.println(i+" "+(char)i); print everytime i press enter a character? It seems to print all at once after everything is entered.
    package stars;
    import java.io.*;
    public class Stars {
      public static void main (String[] args) throws IOException {
        String U="";
        System.out.print("What is your name: ");
        while (true) {
          int i=System.in.read();
          U+=(char)i;
          System.out.println(i+" "+(char)i);
          System.out.flush();
          if (i==10||i==13) break;
        System.out.println("\rHello "+U);
    }C:\>java -cp . stars/Stars
    What is your name: blah
    98 b
    108 l
    97 a
    104 h
    13
    Hello blah
    2. What is the most natural way to check for the press of an enter key? Is there a java attribute or method for the "Enter key" since it is different on unix and ms-dos? Thanks

    On the following code, two questions:
    1. the output is not what I expected. Why doesn't
    the System.out.println(i+" "+(char)i); print
    everytime i press enter a character? From:
    http://scv.bu.edu/Doc/Java/tutorial/java/nutsandbolts/input.html
    ================
    "The read() method provided by System.in reads a single character and returns either the character that was read or, if there are no more characters to be read, -1.
    When a program reads from the standard input stream, the program blocks waiting for you to type something in. The program continues to wait for input until you give it some indication that the input is complete. To indicate to any program that reads from the standard input stream that you have finished entering characters, type the end-of-input character appropriate for your system at the beginning of a new line"
    ================
    In other words, Java can't do what you want to do.
    <snip>
    >
    2. What is the most natural way to check for the
    press of an enter key? Is there a java attribute or
    method for the "Enter key" since it is different on
    unix and ms-dos? Thanks
    System.getProperty("line.separator");Jim S.

  • GX740 - Anyone get two TRUE separate audio streams out Headphones and LINE OUT?

    Hoping for an update on this. I asked MSI via their support section and wow... what a FAIL that was:
    Quote
    Do you have new specific drivers that allow TRUE 4 channel output? 2 out the headphones and 2 separate out the LINE OUT as implied by the design? I've tried everything and it doesn't work.
    I've tried ASIO4YOU drivers - doesn't work.
    I've tried every RealTek driver out there - nothing.
    Yes, I've set the RealTek driver to do multiple out but it sends the audio out the HDMI port, NOT THE LINE!
    I know this can be done cause you can set the REALTEK for 7.1 and you get separate streams out the headphones and line-out ports!
    Please - you've sold a laptop with "Headphone Out" and "Line Out" yet it fails to actually do that - NEW DRIVERS PLEASE?
    Posted: Feb 11, 2011 by Peter Stone
    All Posts
    Dear Customer,
    Please go to msi global website to download the audio driver,then install it.
    audio driver:
    http://www.msi.com/service/download/nbdriver-15227.html
    Needless to say, that did nothing. In fact, I can't understand how I could of received such an answer given it made no sense what-so-ever. Download the driver that came with it? One that's now almost a year old?
    Regardless... I've tried that one. I've tried the latest RealTek drivers. I've tried a multitude of ASIO drivers. NOTHING WORKS. Yes, I've set the RealTek to send TWO SEPARATE STREAMS. That does NOTHING. The only thing I've been able to ascertain is that you can send one stream out the headphone/line out (same thing) AND one out the HD port which is useless.
    Here's the pain in the ass: If you go to the RealTek setup and change it to 7.1 and hit TEST, you DO hear separate output out the HEADPHONE JACK and the THIRD Audio Out jack which is the side fills so I know this laptop CAN spit audio out two separate outputs sitting on the side of the computer.
    Why do I want to do this:
    Simple. I'm lugging around an external audio interface for DJing and it's a pain. I'd rather just tap the headphones out for, well, headphones and send the line out or that third audio output to the DJ mixer. Done! I've tried MIXMEISTER, VIRTUAL DJ, NOTHING WORKS! I can select various strangely named outputs insinuating speaker out, speaker out + 1, etc... but no... it doesn't work at all...
    Sooooooooo... has ANYONE been able to get this to work? I'd love to know...

    Yea Stu... been through this part... Playback devices show the typical:
    1. Speakers (Realtek) -> Plays on ext. speakers but sounds like just treble. Headphone Out plays this stream.
    2. RealTek HD Audio 2nd output -> Plays on ext. speakers but sounds like bass/mids. No treble. NO OUTPUT PLAYS THIS. Plug anything in and sound from the speakers just shuts off
    3. Realtek HDMI Output (Not selectable)
    4. Realtek Digital Output (Not selectable)
    So yea, it seems right out of the box there is a problem with the sound on this unit. Choosing speakers sounds like crap (no mid/bass) and choosing HD Audio 2nd output sounds like crap (all mid/bass no treble).
    There is no discrete dual audio out the jacks.
    HOWEVER - Go choose 7.1 from the realtek setup and do a test. Well what do you know, DISCRETE 2ND AUDIO OUTPUT OUT THE HEADPHONE JACK AND THE 3RD OUTPUT JACK OF THE 4 IN A ROW. This PROVES you can have two discrete stereo audio streams coming out the output jacks. Just need someone to write the driver for it.
    Here's the thing. This laptop HAS 4 1/8" JACKS. SEE:
    Here's what the manual says about the output jacks:
    Mic In:

  • How do I create an application that can be printed AND filled out online via my website?

    Is InDesign the best program to do this in?

    Webform with HTML would be best.
    But depends on a lot of things...
    InDesign is not a web authoring program.
    But it can produce fillable forms ... which are PDF.
    So if you want it on your site - a webform is best.
    If you want it as link they fill out and submit then InDesign.

  • Check-out Exclusive and Check-out Nonexclusive

    Hi,
    When we check out a record exclusively or non-exclusively why is the 'Modify Join Permissions' option active(not disabled).According to my understanding,if we make check-out non-exclusive, without modifying join permission,all the other users must be able to 'Join checkout'.If it is exclusive we have to assign user and role who can Join Checkout it.Then why is the 'Modify Join Permission' option coming for non-exclusive checkout also.Apart from my understanding is there any other difference between the two.Please help me in clarifying this.
    Thanks and Regards,
    Preethi

    Hi,
    (1) Exclusive, which grants join permissions to no other roles or users (by default, no other users can join the checkout); and
    (2) Nonexclusive, which grants join permissions to the Everyone role (by default, all users can join the checkout).
    Instead of checking in the duplicate record, the owner can use the Roll Backcommand to delete the duplicate and abandon changes.
    You can use the All Versions command to display both versions (originals and duplicates) of all checked out records. This is the only way for other users to join the check out of new records.
    You can use role-based privileges to decide whether owners and/or non-owners are permitted to check in, roll back, or modify join permissions of checked out records.
    follow this link:
    http://help.sap.com/search/highlightContent.jsp
    hope this may help you,
    Regards,
    srinivas

  • Strange System.out.print behavior inside a for loop

    I'm trying to create a simple ASCII progress bar in the console that would display like this:
    |--------------------------------------------|
    ============================More equal signs would appear as time goes on. At least this is what I want to happen.
    Instead, what happens is, none of the equal signs are printed until the very end, after the for loop in which the System.out.print("=") statement is in, has exited.
    This is my code (probably more than necessary is shown, but the important part is the for loop):
        public void addSomeDiffys(int numOfDiffys, int minInt, int maxInt) {
            Diffy currentDiffy;
            System.out.println("\nCreating Diffys.");
            System.out.println("|--------------------------------------------|");
            for (int i=0; i < numOfDiffys; i++) {
                currentDiffy = new Diffy(minInt, maxInt);
                if ((i/(double)numOfDiffys)*100 % 2 == 0)
                    System.out.print("=");
                diffyList.add(currentDiffy);           
            System.out.println("\n" + diffyList.size() + " Diffys created.\n");
            System.out.println("Sorting according to highest rating...");
            Collections.sort(diffyList,Diffy.HIGHEST_RATING_ORDER);
            System.out.println("Done.\n");
        }I also tried changing the System.out.print("="); to System.out.println("="); This time it works as expected, its just not very pretty...
    I get something like this:
    |--------------------------------------------|
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =
    =So again, when I use println, rather than print, the equal signs are printed over time, slowly, as the progress increases. When using print, Nothing happens for a long time, and then suddenly they all appear after the for loop has terminated, which makes no sense.
    Thanks for any help.

    When using print, Nothing happens
    for a long time, and then suddenly they all appear
    after the for loop has terminated, which makes no
    sense.
    Yes it does make sense! The characters are buffered inside the PrintStream and written when there is a full line to write. You could try a flush() after each = is written but I have no confidence that it will make any difference.

  • How do I print a interactive form out? It allows printing and filling.

    Hi, I'm trying to print out an interactive form that I filled out and then saved on my hard drive. The author allows printing and filling out of the PDF when it was created. I'm running Windows 7 64-bit and have Adobe Reader XI (11.0.06) installed along with the current drivers for my compatible printer. Within the same PDF the first sheet "instruction sheed" is an all text flat form, which prints just fine. The problem lies when I try to print other sections of the PDF, When I try to print it all I get is the header and a footer that the author created, but all the spaces where questions/ text and my fill in answers don't show up on the print preview image or when the printed sheet comes out of my printer.
         I have tried to print as an image without success. I don't think its an author issuse because it was released out of a California Department for several houndred/thousands of others. Please if you have any ideas or questions i look forward to any advice.

    Sorry I forgot to add that the PDF is devided by a "Chapter" style cover face that devided multiple sets of forms in to categories. At the bottome of these categories is a "Print whole document" which can only be clicked once the whole thing has been filled out. Do to some information over lap some dates don't follow the (time line order) it requirest to fill in the data so two of the categories show up as incomplete. Take a look at the document yourself, maybe I NEED to rewrite the information and see if that works.
    *Edit* Looks like I CAN print a blank form at the begining when it asked me if i want a blank form, will try to rearange dates so it will show as all COMPLET.
    PDF file can be found at the California government website:
    http://www.chp.ca.gov/recruiting/pdf/Chp446.pdf
    http://www.chp.ca.gov/recruiting/pdf/Chp446.pdf

  • [SOLVED] system-config-printer won't update or install

    After unsucessful update, i uninstalled system-config-printer and tried to reinstall but i get this message:
    sudo pacman -S system-config-printer
    resolving dependencies...
    looking for inter-conflicts...
    Packages (4): python2-gobject-3.12.1-1 python2-pycups-1.9.66-2
    python2-pycurl-7.19.3.1-2 system-config-printer-1.4.4-1
    Total Installed Size: 8.99 MiB
    :: Proceed with installation? [Y/n] y
    (4/4) checking keys in keyring [######################] 100%
    (4/4) checking package integrity [######################] 100%
    (4/4) loading package files [######################] 100%
    (4/4) checking for file conflicts [######################] 100%
    error: failed to commit transaction (conflicting files)
    system-config-printer: /usr/share/system-config-printer/debug.pyc exists in filesystem
    Errors occurred, no packages were upgraded.
    Is there something wrong on my system, or this is a packaging error that will be fixed quickly?
    Last edited by max kaspar (2014-04-18 23:11:52)

    max kaspar, please edit your post - the bright yellow is hard on the eyes.
    When posting configs, code or command output, please use [ code ] tags https://bbs.archlinux.org/help.php#bbcode
    like this
    It makes the code more readable and - in case of longer listings - more convenient to scroll through.
    *.pyc files can cause a conflict like that, usually you can remove them, as they don't belong to any package.

  • System-config-printer-gnome utility freezes when "adding" printer.

    I've just started adding my wireless printer to my desktop, and while reading about CUPS in the archwiki, I discovered "system-config-printer-gnome". I installed it with pacman, and then set it up like the wiki said. Now when I run system-config-printer and press "Add", I get this error output in my terminal:
    [mike@mike-desktop ~]$ system-config-printer
    Traceback (most recent call last):
    File "/usr/share/system-config-printer/asyncipp.py", line 196, in send_reply
    handler (self._conn, result)
    File "/usr/share/system-config-printer/asyncpk1.py", line 143, in _ipp_reply_handler
    self._client_reply_handler (self._conn, *args)
    File "/usr/share/system-config-printer/asyncconn.py", line 142, in <lambda>
    kwds["reply_handler"] = lambda c, r: reply_handler (self, r)
    File "/usr/lib/python2.6/site-packages/cupshelpers/cupshelpers.py", line 575, in _reply_handler
    self._client_reply_handler (connection, devices)
    File "/usr/share/system-config-printer/system-config-printer.py", line 4820, in <lambda>
    current_uri))
    File "/usr/share/system-config-printer/system-config-printer.py", line 4858, in local_devices_reply
    self.add_devices (result, current_uri)
    File "/usr/share/system-config-printer/system-config-printer.py", line 5198, in add_devices
    physdev = model.get_value (iter, 1)
    TypeError: iter must be a GtkTreeIter
    Does anyone know what could be wrong? I've done some Googling, but couldn't find anything related to this. I also couldn't find anything related to setting up a wireless printer manually with CUPS, so this way seemed the easiest way of adding a printer. Thanks
    P.S. I am using GNOME, and all my packages are up to date.

    skunktrader wrote:Did you try pointing your browser at http://localhost:631/admin and attempt to add your printer from there?
    Oh wow. That worked perfectly! I guess when I saw that in the wiki I assumed that it was for USB or parallel port printers since I saw "localhost". Sorry to waste thread space!
    Thanks so much guys!
    P.S. I feel like such a noob

  • Can an old iMac G3 drive running system 10.2.8 and system 9 be mounted in the secondary drive bay of a G4 800 Mhz running 10.4.11 and boot from the 10.2.8?

    I've done this and the G4 800 Mhz boots up from system 9 on the old iMac G3 just fine, but when I boot up from its system 10.2.8, it runs for only 5 minutes or so and the grey screen comes down telling me to re-boot.  I've run Norton on the system 9 disk and system 10 disk utilities on the system 10 disk of the old iMac G3 and all is fine with it.  Is there some incompatibilities with running the old iMac G3 230 Mhz from the G4 800 Mhz that causes this to happen?  I can access all my old files on the iMac G3 when I boot up with extensions off (holding down the shift key when I boot up), but I would like to be able to use the USB functions when I boot it up.

    It sounds like you have a Power Mac G4 Quicksilver 2002, and according to the program Mactracker, it should be able to run on the OS 9 and the OS 10.2.8.
    I don't know which version of Norton (Utilities?) you ran on the old iMac drive, but I suspect that might be the problem.  This is from the iMac Tray Loading Service Source Manual:
    HFS Plus Formatted Drives
    The hard drive in the iMac is formatted with HFS Plus (also referred to as Mac OS Extended format). It is important to note that Norton Utilities version 3.5 is not compatible with HFS Plus (or Mac OS Extended format), and in fact, can destroy data on the hard drive.
    Norton Utilities version 3.5.3 or 3.5.2 will not attempt to repair a drive formatted with Mac OS Extended format and versions 3.5.1 and earlier cannot recognize that a hard drive is in Mac OS Extended format and can result in hard drive corruption and loss of all data on the drive.
    Note: When diagnosing hard drive problems, it is important to verify whether or not the customer may have used the wrong disk repair software for their drive before assuming that the problem is hardware related.
    If you experience problems with a hard drive that has been formatted with HFS+, Apple Computer recommends using Disk First Aid 8.2 (which is included on the system software CD that ships with the iMac). Disk First Aid 8.2 can be used to recover data that may have been deleted by Norton Utilities. (See the Symantec Web site at NO LONGER A VALID LINK-REMOVED FROM ARTICLE for more information on Norton Utilities and Mac OS Extended format.)
    Some other disk utility and disk locking programs are incompatible with Mac OS Extended format. Before you attempt to use a disk utility or disk locking program, make sure the version you have is compatible with Mac OS Extended format. Check the documentation that came with the program or contact the manufacturer or the vendor that supplied the program.
    Use the Get Info command in System 8.1 to determine how a hard drive has been formatted. Drives formatted with HFS will appear as “Mac OS Standard”, while drives formatted with HFS+ will appear as “Mac OS Extended.”
    I hope some of this helps.
    Good luck.

  • Problem with HP 3600n Color Laserjet Printer and new HP Notebook Running 64 bit Win7

    I have a new HP notebook (dv7t-6100) with Core-i7 Processor, running 64 bit Windows 7 with all of the latest updates.
    I also have a 27" iMac with Core-i7 Processor running 64 bit Windows 7 underneath Parallels 7. Parallels is a program that creates a virtual machine underneath Mac OSX.
    Both versions of 64 bit Windows 7 work perfectly . . . EXCEPT, neither will print from my HP 3600n Color Laserjet. The iMac will print to the 3600n in OSX mode, and an earlier version of 32 bit Windows 7 under Parallels printed perfectly with this 3600n printer.
    These facts prove that the printer is OK, the connection is OK. However, the 64 bit Windows 7 systems do not print.
    In both of the 64 bit Windows 7 installs I allowed Windows to find and download the HP driver for this printer. Install of the driver was apparently successful. Still no printing. 
    One strange fact: Sometimes when I turn the computer off, the 3600n printer will print the items that had been in the queue before powering down. That is the only time it has printed anything . . . except under OSX on the iMac.
    Does anyone know if there is a basic problem with 64 bit Windows 7 and this printer ?
    Thanks for any help you can provide.

    I just had the same problem with my MacBook Pro using 10.5.5 After trying a number of things, the following worked. (not sure what specifically ... just did this combination)
    1. Had the Apple store Genius Bar folks install the latest HP drivers.
    2. Restart computer
    3. Restart the HP Color LaserJet 3600
    4. Connected the HP printer and MacBook Pro directly into a switch, so the wireless was not an issue (both machines had IP addresses set and computer's was set to DHCP with manual IP).
    5. Instead of using the System Preference printing and fax tool, I started Text Edit, typed something and said "print".
    Print window came up and said "no printer selected"
    6. I clicked on the drop down so it would look for printers.
    7. It found the HP Color LaserJet 3600.
    8. I clicked on the name of the printer and the computer went out and found the driver
    9. I clicked on "Add" and it added the printer.
    10. I tried a couple of test prints in different programs.
    11. I disconnected the hard wired ethernet cables and set the computer to be on the wireless.
    12. I printed a few more test prints in various programs.
    I had previously tried selecting the printer and drivers through the System Preferences to no avail, but doing it this way worked.
    Blessings

  • Missing Print and Fax Preferences - no joke

    I am logging onto my grandmother's brand new MacBook & trying to setup a printer for her. It has been a fiasco, which as a major Mac head is not a familiar feeling. I comfortably identify myself as expert on the user & support side.
    After a few hours of fighting with her existing printer when I was there at the holidays, I ascertained that it had lost its little USB brain. HP sent out a new printer & I got her to plug it in and ran the setup assistant for her. All is well. I went to print and it stalled. Kept trying to connect, no dice. I hit the pulldown. 2 copies of the printer. Printed to the 2nd copy...all good. Great. Now I'll just delete the 1st one so she's not confused.
    I go to System Preferences. No icon for Print and Fax Preferences. I hit the 'show all' button. Nothing additional. I search for print in the search window on the preferences app. Nothing. Did they move it in 10.5? I check the help file...no it says go to system preferences>print and fax.
    So what gives? How do I resolve this and retrieve the print and fax preferences? Wanna see the window for yourself? http://www.killerbanshee.com/noprintfaxpreferences.png
    (It is black & white cuz I was running it black and white to have faster screen response over a remote connection.)
    Thanks,
    Kriss

    Does /System/Library/PreferencePanes/PrintAndFax.prefPane exists ?
    Also, please provide any information available in Console (/Applications/Utilities/Console) when you launch System Preferences.

  • Printing and language problem after re-installing BasePackage-Leopard ques?

    I reinstalled BasePackage system as advised only it seems I reinstalled the entire package. What happened? It restarted and I received the window as if the computer was new and I had to fill in all the appropriate info. Well it worked fine saving all my settings etc. and I was able to verify permissions and repair. However MAIL started acting up and requested the password for my mail several times until I think that is solved.
    But I have several problems now. I work with Arabic and Hebrew going over from the keyboard 'command/space' and now with this command I get Spotlight. On my word processor Nisus or Mellel or on TextEdit even if I click on the Hebrew/Arabic icon and also choose the appropriate Hebrew/Arabic font it will only write in English.
    Aside from this I cannot print at all. I am using HP LaserJet 5MP with AppleTalk thru an ethernet connection on my router because of the outdated technology.I am using a 'bridge' from Asante technology for this.
    I have an external Firewire HD which I have started up from now and I can print from this and have no problems with the Hebrew/Arabic.
    Also I have not gone over to Leopard for the following reason. As mentioned above I am using a bridge thru ethernet to facilitate my printer. I have been told by many who have also not gone over to Leopard that there are driver problems with printers. Has this been fixed? Is it applicable to my situation?
    Any help much appreciated.
    Thanx.
    Safed

    I work with Arabic and Hebrew going over from the keyboard 'command/space' and now with this command I get Spotlight.
    You need to set the shortcuts in system prefs/spotlight and system prefs/keyboard and mouse
    On my word processor Nisus or Mellel or on TextEdit even if I click on the Hebrew/Arabic icon and also choose the appropriate Hebrew/Arabic font it will only write in English.
    That sounds bad. You might try setting up a new user account and see if it works when you are logged in there. If not, I would reinstall the OS.
    None of these issues really have anything to do with the mini as such, so it might be better to post in the forums for Tiger:
    http://discussions.apple.com/forum.jspa?forumID=758
    http://discussions.apple.com/forum.jspa?forumID=756
    And to post your question about Leopard in its printing forum:
    http://discussions.apple.com/forum.jspa?forumID=1224

  • What is the different  between System.out.println and out.print

    we move a project , jsp form to servlet to mysql db
    suddenly we get Chinese input problem
    on meantime only Thing I know is
    if( chineseName!=null) {
                           chineseName= new String( chineseName.getBytes("ISO-8859-1"),"UTF-8");
                         out.print(chineseName); //display Chinese
                          System.out.println("Hello1"+chineseName ); // display unread symbol
                 }I don't know why when we insert the value into db by StudentInsert(university_ID, surName, english_Name, chineseName, Address)
    the db get the value from System.out.println
    what setting decide my out put through System.out.println

    Thank you for the reply!
    after two days of search and guess.... I found out
    for Web application , which under glassfish , you need to put your jsp page under WEB-INF,
    other wise the server jsp turn your Chinese character that come from jsp request form to UTF8 symbol.
    not ideal how to change the configuration in glassfish yet!

Maybe you are looking for

  • Why Does the Photograph's Preview Change in Lightroom and Bridge? | The Complete Picture with Julieanne Kost | Adobe TV

    In this video tutorial Julieanne explains one of the great mysteries of Lightroom and Bridge – why Lightroom (or Bridge) displays a photograph one way and then changes the way it looks a moment later. It will all become clear with just a little infor

  • DVI Connector faulty?

    Hi all, I just purchased the MacBook with the Mini DisplayPort to DVI Connector The DVI Connector worked really well the past few days to connect my external LCD However, today it won't connect. When the adapter (with the cable attached) is plugged i

  • As2 and As3 on same Flash Player

    If i set AS2 codes to play in Flash Player 9, is it possible that this swf can load an As3 swf at the same Flash Player using As2 codes??? These swfs both play in same virtual machine which is player version 9 but the other is coded with As2 and the

  • Help w/ E-mail and Director

    Hey all. I need to find code for Director to access G-Mail. I want to be able to recieve and send mail. And then take those e-mails and take information from them and use it in the shockwave file. Is there anyway I can do this?

  • Quick question about Photoshop and Bridge

    If someone purchases the Standard Photoshop software, does Bridge come with it? I think it does, but I am not sure.