@@ -0,0 +1,1491 @@
+package nricheton.utils.io;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.UnsupportedEncodingException;%0A%0A/**%0A * This input streams removes invalid XML Characters from the stream. As a%0A * result you should be able to read invalid documents.%0A * %3Cp%3E%0A * %3Cp%3E%0A * Feel free to submit patchs on this class.%0A * %0A * @author Nicolas Richeton%0A * %0A *%0A */%0Apublic class XmlCleanupInputStream extends InputStream %7B%0A%0A%09private static final String ENCODING = %22UTF-8%22;%0A%09private InputStream originalIS;%0A%09private BufferedReader originalReader;%0A%09private byte%5B%5D buffer = new byte%5B0%5D;%0A%09private int position = 0;%0A%09UnsupportedEncodingException error = null;%0A%0A%09public XmlCleanupInputStream(InputStream is) %7B%0A%09%09originalIS = is;%0A%09%09try %7B%0A%09%09%09originalReader = new BufferedReader(new InputStreamReader(originalIS, ENCODING));%0A%09%09%7D catch (UnsupportedEncodingException e) %7B%0A%09%09%09error = e;%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public int read() throws IOException %7B%0A%09%09if (error != null)%0A%09%09%09throw new IOException(error);%0A%0A%09%09if (buffer == null)%0A%09%09%09return -1;%0A%0A%09%09while (position %3E= buffer.length) %7B%0A%09%09%09String temp = originalReader.readLine();%0A%09%09%09String temp2 = null;%0A%09%09%09if (temp != null) %7B%0A%09%09%09%09temp2 = temp.replaceAll(%22%5B%5E%5C%5Cx20-%5C%5Cx7e%5D%22, %22%22);%0A%0A%09%09%09%09buffer = temp2.getBytes(ENCODING);%0A%09%09%09%09position = 0;%0A%09%09%09%7D else %7B%0A%09%09%09%09buffer = null;%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09if (buffer == null)%0A%09%09%09return -1;%0A%0A%09%09int result = buffer%5Bposition%5D;%0A%09%09position++;%0A%0A%09%09return result;%0A%09%7D%0A%0A%7D%0A

Create XmlCleanupInputStream.java