Is there any character limit for the output of Java's System.out.println(String x)
statement?
When I try to print some XML from a web service call using System.out.println()
, only a portion of it is actually printed in the console.
The XML string that I am trying to print is huge.
Why is this happening?
Therefore, the maximum length of String in Java is 0 to 2147483647. So, we can have a String with the length of 2,147,483,647 characters, theoretically.
While an individual quoted string cannot be longer than 2048 bytes, a string literal of roughly 65535 bytes can be constructed by concatenating strings.
println(): As all instances of PrintStream class have a public method println(), hence we can invoke the same on out as well. This is an upgraded version of print(). It prints any argument passed to it and adds a new line to the output.
Are you experiencing this within Eclipse? If yes:
EDIT:
Source
My guess is that you only see the last part of the String because the console has a limited number of lines it can display.
Consider logging to a file from Java, or redirecting the standard output from the program to a file:
java com.foo.bar.Main > output.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With