Im working with flying saucer and want to export an xhtml to an pdf. Everything works fine, but now I want to add an empty column, for example for descriptions or something.
I want to create a method addColumn(). which should add in every row of the table at the end a new, empty cell.
I tried following code:
String[] arr = content.split("<td");
String test = "";
for (int i = 0; i < arr.length; i++) {
if(i != 0){
arr[i] = "<td" + arr[i];
test += arr[i];
}
}
This should split the content on every beginning "td"
tag.
String.split("<td")
removes the "<td"
from the content so i want to add it again.
But if i compare those:
if(test.equalsIgnoreCase(content)){
System.out.println("SUCCESS");
}
else{
System.out.println("FAIL");
}
I always fail.
Just help me to get the right content back out of the array, this would make me go a step in the right direction!
Thank you.
Try to replace your
split
line with this:Otherwise you will loose some input in
arr
, see thesplit(String)
API doc:The added
-1
makes sure that yourcontent
can also contain"<tr"
at its beginning, for example. See thesplit(String, int)
API doc for further explanations.