2 Replies Latest reply: Jan 22, 2004 12:09 PM by 800387 RSS

    How to get the system's tab character

    807582
      To get a system's end-of-line character, I use the following call:

      System.getProperty ("line.separator");

      Is there a similar method for obtaining the system's tab character?

      thanks,
      Andrew
        • 1. Re: How to get the system's tab character
          807582

          Why not use "\n" for newline and "\t" for tab ?

          regards,
          Owen
          • 2. Re: How to get the system's tab character
            800387
            You do not necessarily want to use '\n' as a global newline. Better to make a static variable that is available in an interface that queries line.separator once:

            static final public String EOL = System.getProperty("line.separator");

            Regarding the tab character (and the newline as well), the special characters ('\t', \n', etc.) can be encoded for something other than UTF-8. The most likely example would be if you have to write a legacy interface for an EBCDIC mainframe or mini-computer. In this case, you can somewhat guarantee the correct output by:

            Writer writer = new OutputStreamWriter(out, encoding);

            - Saish

            "My karma ran over your dogma." - Anon