That means your document isn't actually encoded in UTF-8, but you are reading it as though it were. This is often because whoever created the document failed to specify its encoding in the prolog.
So send it back to whoever created it and ask them to fix it up. If you don't feel you have the technical background to back up that claim yourself (and you probably shouldn't) then read this tutorial first:
I got the same exception. Fortunately, I resolved in the following ways, this code will help for others.
String output = "some contents...go here."; //or input from other
String s = new String(output.getBytes(),"UTF-8");//force to convert UTF-8 standard will address this issue Invalid byte 1 of 1-byte UTF-8 sequence
Writer writer = new BufferedWriter(new FileWriter("c:/temp/Jasper/invoice.html"));
try{
writer.write(s);
}finally{
writer.close();
}
That may work in the sense that it won't throw the exception any more. It may not prevent damage to the data caused by failing to read the document using UTF-8 in the first place.
You may well have seen pages on the web with things like Euro signs and A-with-a-hat characters where there should have been quotes or dashes. This is the sort of thing that happens if you don't use the right encodings.