While debugging Java code, Strings in the views "Variables" and "Expressions" show up only till a certain length, after which Eclipse shows "..."
Is there any way to inspect the entire string? (This eases the pain of adding logging statements for debugging everywhere)
In the Variables view you can right click on Details pane (the section where the string content is displayed) and select "Max Length..." popup menu. The same length applies to expression inspector popup and few other places.
https://i.stack.imgur.com/eWgSM.png
In the Variables view you right-click on the variable and select Change value. If your variable is huge you have to wait a few minutes (in this case Eclipse doesn't respond to commands) but in the end Eclipse will show your variable entirely.
"data:image/bitmap;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQE... (length: 22869)"
. Set "Max Length" option not work and "Change value" also.
If you have a really long string, I use a different strategy: dump it to a file. I have a snippet of code I use in the Display view, which is evaluated to dump the data to a file. I use Commons IO, but you can do it with JDK only methods.
org.apache.commons.io.FileUtils.writeStringToFile(new java.io.File("<filename>"), <expression to evaluate>);
Naturally, you will need the Commons IO JAR in your classpath for that to work. If you don't, resort to JDK work.
The best way to view a String value from eclipse debug view is as below.
1) Switch to debug view in Eclipse
2) Select the desired variable in variable pane.
3) Right click on display area of variable pane where value is shown and click on Max Length. Enter the maximum char value in Configure Details Pane .
4) Cheers
https://i.stack.imgur.com/EWS69.png
When debugger reaches the point where you want the String value, just type a sysOut statement
System.out.println("The value is : \n " + query);
Select the above the statement, right click-> Execute
It will print the value on the console
For javascript based debugging on eclipse, "change value" method and "Max length" method both failed for me, adding the required object to watch(Expressions) and then Right Clicking the watched expression to select "Load Full Value" is the only solution that works for me, but even this inserts unwanted "\n" in the output.
Note - "Max length" must be set for the "Load Full Value" to work as it loads values till max length(default in eclipse is 10000). Refer above answer to see how to set Max length.
There is no "maxLength" in Eclipse Mars. And, the "change value" only works with "Variables", not "Expressions", so none of above works for me.
https://i.stack.imgur.com/TwjCv.png
And, the expression are cut in the middle, not at the end. I guess they changed the default behaviour.
The only thing working for me, is to expand the expression name column's width, and click the expression to select it all to see the full length content.
Nothing from the above worked for me, moreover, some user interface elements in my Eclipse can not be found as described. I'm using STS 4.3.1.
The value I needed was really big, it is part of a huge JSON request. Workaround is to use an expression in Eclipse Debug Shell console and to output the substring of the whole value. Since you can see the partial value, inspect it and use the last few literals as the position to output the next chunk of the string. Repeat this approach until get what you need:
String result = new String(reallyBigByteArrayValue, "UTF-8");
result.substring(result.indexOf("some-unique-text"));
https://i.stack.imgur.com/zMyNe.png
From the console the copying is possible at full length.
Success story sharing