Trouble Outputting Lines with '<' and '>'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Techninjaz
    New Member
    • Jan 2010
    • 5

    Trouble Outputting Lines with '<' and '>'

    We've been having this issue where System.out.prin tln() will totally ignore a line that contains '<' or '>'.

    Is there some sort of escape character that we need to output these lines?
  • pbrockway2
    Recognized Expert New Member
    • Nov 2007
    • 151

    #2
    Those characters are not special in any way.

    Of course the text which is output and that includes them might be interpreted in a special way by other software - web browsers and the like might regard them as part of HTML tags for example.

    Perhaps you could post a brief example that illustrates the problem.

    Comment

    • Techninjaz
      New Member
      • Jan 2010
      • 5

      #3
      Certainly.

      My friend and I are working together on a project and this is his script that I'm referring to. I don't know too much about the specifics of the project in terms of source, but I could certainly go through it if another question needs answering.


      Code:
      line = "<tile" + tileCount + " collision=\"" + map[C][x][y] +
      					"\" image=\"" + map[I][x][y] + "\" x=\"" + x + "\" y=\"" +
      					y + "\"/>";
      System.out.println(line);

      He even put:

      Code:
      System.out.println("<");
      System.out.println("End Test");
      before any of the other code to test his theory.

      As he expected, the code only output a blank line before "End Test".

      Comment

      • pbrockway2
        Recognized Expert New Member
        • Nov 2007
        • 151

        #4
        Your Java appears to be broken then. (Or you're simply not describing the problem in a way that allows others to reproduce it.)

        For example:

        Code:
        C:\>type AngleBrackets.java
        public class AngleBrackets {
            public static void main(String[] args) {
                System.out.println("<");
                System.out.println("End Test");
            }
        }
        
        C:\>"C:\Program Files\Java\jdk1.6.0_17\bin\javac" -cp . AngleBrackets.java
        
        C:\>"C:\Program Files\Java\jdk1.6.0_17\bin\java" -cp . AngleBrackets
        <
        End Test
        
        C:\>
        Note the output in the fourth to last line.

        Comment

        • Techninjaz
          New Member
          • Jan 2010
          • 5

          #5
          That's very interesting.

          Obviously, he must have messed something up in the source. I'll look through it.

          Many thanks!

          Comment

          • pbrockway2
            Recognized Expert New Member
            • Nov 2007
            • 151

            #6
            You're welcome.

            Bear in mind what I said before: if you are looking at the output via anything that wants to interpret the string as html, xml etc, then you won't see the angle brackets. (Hence my example deliberately quoted from the command line.)

            Comment

            Working...