1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
package com.onyme.engine.processors;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Vector;
class ProcessThreads extends Thread {
public static final int T_OUT_MODE = 1;
public static final int T_ERR_MODE = 2;
private Process process;
private int mode = 0;
private Vector<String[]> result = new Vector<String[]>();
public ProcessThreads(Process p, int m) {
process = p;
mode = m;
if (mode == T_OUT_MODE)
this.setName("T-OUT");
if (mode == T_ERR_MODE)
this.setName("T-ERR");
}
public void run() {
try {
BufferedReader reader = null;
if (mode == T_OUT_MODE)
reader = new BufferedReader(new InputStreamReader(process
.getInputStream(), "ISO-8859-1"));
if (mode == T_ERR_MODE)
reader = new BufferedReader(new InputStreamReader(process
.getErrorStream(), "ISO-8859-1"));
String line = "";
String[] lalignesplit = null;
try {
while ((line = reader.readLine()) != null) {
if (mode == T_OUT_MODE) {
lalignesplit = line.split("[\\t]");
result.add(lalignesplit);
}
if (mode == T_ERR_MODE) {
// System.out.println("ERR:"+line);
// lalignesplit = (new String(line)).split("[\\W]");
}
}
} finally {
reader.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
public Vector<String[]> getResult() {
return result;
}
public void setResult(Vector<String[]> result) {
this.result = result;
}
} |
Partager