Author: kcardineaud Date: 2011-05-17 16:34:48 +0200 (Tue, 17 May 2011) New Revision: 582 Url: http://nuiton.org/repositories/revision/jrst/582 Log: Modification de ThreadRedirection.java pour l'utiliser avec des sorties de type HTML Modified: trunk/jrst/src/test/java/org/nuiton/jrst/ThreadRedirection.java Modified: trunk/jrst/src/test/java/org/nuiton/jrst/ThreadRedirection.java =================================================================== --- trunk/jrst/src/test/java/org/nuiton/jrst/ThreadRedirection.java 2011-05-17 14:17:34 UTC (rev 581) +++ trunk/jrst/src/test/java/org/nuiton/jrst/ThreadRedirection.java 2011-05-17 14:34:48 UTC (rev 582) @@ -29,10 +29,15 @@ import java.io.IOException; import java.io.InputStreamReader; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * Class qui redirige la sortie standard pour la laisser en interne */ public class ThreadRedirection extends Thread { + private static Log log = LogFactory.getLog(ThreadRedirection.class); public static final String LINE_SEPARATOR = "\n"; protected StringBuffer str; protected Process process; @@ -44,24 +49,38 @@ @Override public void run() { + BufferedReader reader =null; try { - BufferedReader reader = new BufferedReader(new InputStreamReader( - process.getInputStream())); - try { + + reader = new BufferedReader(new InputStreamReader( + process.getInputStream()),8193); + String line; while ((line = reader.readLine()) != null) { - str.append(line + LINE_SEPARATOR); + + /*Le doctype est modifie pour eviter que sax telecharge la DTD du HTML sur le net, car le traitement prend un certain temps. + On doit en revanche spécifier la signification de nbsp. + */ + + if(!line.equals("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")) + { + str.append(line + LINE_SEPARATOR); + } + else { + str.append("<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp \" \">]> " + LINE_SEPARATOR); + } } - } finally { - reader.close(); + } - } catch (IOException ioe) { + catch (IOException ioe) { ioe.printStackTrace(); - } + } + finally { + IOUtils.closeQuietly(reader);} } public String getOutput() { - return str.toString(); + return str.toString(); } }
participants (1)
-
kcardineaud@users.nuiton.org