29

In Java I tried to write a String as an output to the console. The length of the String is 20166 characters. After printing the string to the console only second half of the String appears.

The whole string is one long line:

What it looks like: From the beginning there is a lot of whitespaces (which are supposed to be alphanumeric characters) and after that there is the rest of the string displayed properly.

I tried to change console encoding from default to UTF-16 and UTF-8, but it didn't help.

The String I am trying to output is text content crawled from a specific webpage (http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery). If I crawl a different webpage there is no problem.

How I process the string: I use a webservice to get the text content from the webpage. The returned String (text contet) is printed properly (whole). I need to process this string so I change all characters to lowercase and replace all multiple whitespaces with the single one.

textContent.toLowerCase().replaceAll("\\s+", " ");

After lowercasing the characters I am still able to print whole string properly, but after replacing the multiple whitespaces with one, the beginning of string is not visible.

Do you have any idea what the problem is?

Thakns in advance for any help.

CSharpened
  • 11,674
  • 14
  • 52
  • 86
mimo
  • 6,221
  • 7
  • 42
  • 50
  • does it happen only with eclipse? I mean, have you tried running it from the console and the result is what expected? – fortran Feb 16 '12 at 14:25
  • Possible duplicate of [Character limit for System.out.println() in Java](http://stackoverflow.com/questions/8912202/character-limit-for-system-out-println-in-java). – Ole V.V. Feb 23 '17 at 09:31
  • Have this with the output of longer, line-separated base64 Strings: Regularly, when a line starts with '+', it is omitted, for some reason ;) – Sam Ginrich Jan 05 '22 at 08:24

4 Answers4

48

This is no bug. It is 1 of the changeable settings that Eclipse includes to make the output more readable.

It can be changed by going to Windows --> Preferences --> Run/Debug --> Console and then unchecking "Limit Console Output" which is ON by default.

For more information and details about these settings visit: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Frun-debug%2Fref-console.htm

This works on STS any version too. This would help printing complete console output.

Raj
  • 59
  • 1
  • 10
Menezes Sousa
  • 1,448
  • 2
  • 18
  • 18
  • 1
    For a Mac it is Eclipse > Preferences > Run/Debug > Console. And yes, this should be the accepted answer. – Munib Nov 30 '16 at 18:32
  • You can create a file for the logs or if html, see the source code that's what I did to see all output. – Ricky Vene Oct 05 '22 at 19:54
37

What are the preferences for the console? Especially check the settings "Fixed width console" plus "Limit console output". Maybe your console simply can't hold that many characters in one line.

In Eclipse if you go to preference and in the drop-down, you can see RUN/DEBUG option if you click on that RUN/DEBUG drop-down you can see the console button and there you can adjust the "Fixed width console" plus "Limit console output"

[EDIT] Now Eclipse eventually has to cut the data in the console since it doesn't have infinite amounts of memory. If the console is still cut off, you can use this trick: Open the "Run Configurations" dialog (Found in the drop down menu for the green "run" button).

The tab "Common" tab has options in the "Standard Input and Output" group at the bottom to save a copy of all output in a file. You can then use your OSs tools to examine this file.

Also note that very long lines can make Eclipse slow (i.e. it can hang for a couple of seconds). This is due to a bug in the regexp matching patterns for Exception stack traces. If that happens, limit the line length to 1000 characters or less.

This is especially a problem with Spring which sometimes creates exceptions that have 50'000 characters in the message.

If you have a similar problem with the CDT Global Build Console, see here: Eclipse CDT Build Console output not displaying entire compiler output

Meena O
  • 29
  • 1
  • 11
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • After setting 'Fixed width console' I can see whole output. Thanks for solving the problem. But do you have any idea about the cause? Could it be Eclipse bug? – mimo Feb 16 '12 at 15:06
  • Hi, I'm using eclipse Kepler, I've unchecked the option to limit the console output length and yet it is still cutting off the start of the log when it gets too long, which makes debugging /very/ hard considering I can't find the root cause... I think this must be an eclipse bug, is there a workaround? – Troyseph Oct 03 '14 at 10:28
  • @SebastianTroy: Please ask a new question - other people probably have the same problem. – Aaron Digulla Oct 03 '14 at 11:17
  • @AaronDigulla: Surely it would immediately be marked as a duplicate of this question? – Troyseph Oct 03 '14 at 11:24
  • It should also be noted that the console output is only written to the file when the project is run, not when the project is built... – Troyseph Oct 03 '14 at 11:58
  • @AaronDigulla in my case, I'm using JNI so my project has both Java and C++ affinities so the CDT Global Build Console appears in the console tab when I build my C++ code, the output of which does not get included in the Java console file. – Troyseph Oct 03 '14 at 12:36
  • @SebastianTroy: I know nothing about CDT but I guess that makes sense since building C/C++ code is ... noisy (Makefiles and such). My question is only about JDT. For CDT, create a new question. – Aaron Digulla Oct 03 '14 at 14:19
  • @AaronDigulla I see your point, this really is a separate question, plus I now know the answer so I guess I should share it! – Troyseph Oct 03 '14 at 15:48
1

Check this bug: Long Lines not printed to console, which is a duplicate of Bug 23406, opened in 2002 and not fixed yet! I just discovered it in Eclipse 2020-06, then I tried also the very old Ecipse Mars and it works. They says that the problem affects not only the console but also editors. A comment says "This bug has too many dups for a WONTFIX".

Pino
  • 7,468
  • 6
  • 50
  • 69
1

Check whether the console buffer size is enough for your case, in Preference. Usually it's 80000 characters, just in case it's been changed.

Qishan
  • 165
  • 2
  • 12
  • I changed the buffer size to unlimited by unchecking the 'Limit console output', I forgot to mention it in my post. – mimo Feb 16 '12 at 15:04