Page 2 of 2 FirstFirst 12
Results 21 to 27 of 27
  1. #21
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: How to I print a symbol?

    Quote Originally Posted by anandkesari01 View Post
    Try out this
    System.out.println((char)163);
    That works if you switch 163 with 339.
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  2. #22
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,363
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to I print a symbol?

    People, please ... the 'standard' output stream is an OutputStream; it writes bytes; you want to write characters to it so you have to encode those characters to byte values; the OutputStreamWriter class was made for this; all you have to know is the encoding used by your console; use that encoding when your create your OutputStreamWriter and you're in business ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #23
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: How to I print a symbol?

    The Console class takes care of encoding too, but since Jos and I haven't posted any responses in this thread, nobody else here has ever heard of OutputStreamWriter and Console.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #24
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: How to I print a symbol?

    Darryl's link contains all the info the OP needs.
    Anything else is just making up stuff in an attempt to find the correct DOS code point.

    Indeed, it's possible that the character set the OP is using does not have a sign, as it's not one of the first 128 ascii characters.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #25
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: How to I print a symbol?

    Quote Originally Posted by Tolls View Post
    Darryl's link contains all the info the OP needs.
    Anything else is just making up stuff in an attempt to find the correct DOS code point.

    Indeed, it's possible that the character set the OP is using does not have a sign, as it's not one of the first 128 ascii characters.
    I tried the solution that Darryl linked to and it works perfectly. It's probably the best solution, but I wouldn't know.

    However, surely the person in this thread wasn't just "making up stuff" when he discovered that assigning the value of 339 to a char reference would produce the pound symbol (and that it can be printed via the standard output stream). Can anyone here explain why this works?
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  6. #26
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,820
    Rep Power
    19

    Default Re: How to I print a symbol?

    All down to the character set used by their DOS terminal.
    Whatever they had obviously had 339 mapped to .
    Essentially, at the time DOS was growing up character sets were a mess...
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #27
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: How to I print a symbol?

    Quote Originally Posted by Tolls View Post
    All down to the character set used by their DOS terminal.
    Whatever they had obviously had 339 mapped to .
    Essentially, at the time DOS was growing up character sets were a mess...
    Hey Tolls!

    Thanks for the reply. I really should have posted a comment here directing anyone to this thread because I realize that I essentially cross-posted. To save you the trouble, pbrockway2 (Edit: and eRaaaaa) helped out and I decided that I need to gain a better understanding of input/output in Java before I tackle this problem again.

    Andrew
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Javax Print Attribute for Selection Print Range
    By rsawatzky in forum AWT / Swing
    Replies: 0
    Last Post: 04-26-2012, 12:14 AM
  2. '@' Symbol
    By AedonetLIRA in forum New To Java
    Replies: 5
    Last Post: 12-09-2010, 01:05 AM
  3. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  4. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-22-2008, 11:04 PM
  5. Replies: 3
    Last Post: 05-01-2008, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •