[jdom-interest] outputter w/ socket streams
Scott Jeppensen
scott at visionairemedia.com
Thu Mar 8 10:34:25 PST 2001
I am having problems outputting my XML doc through an outputstream. With
the code supplied below, I know the doc is reaching the outputter because if
I use:
outputter.output(doc,System.out);
then the XML prints out fine...if I use:
outputter.out(doc, out);
then nothing....no errors, no excpetions, etc...
Here is the JDOM part of my code(using JDOM b6):
class flashClientThread extends Thread {
private Socket clientSocket = null;
public String clientIP;
public PrintWriter out;
public BufferedReader in;
public InputStreamReader inP;
int i;
int end;
int begin;
public String contact = null;
public flashClientThread(Socket clientSocket) {
super("flashClientThread");
this.clientSocket = clientSocket;
}
public void run() {
clientIP = clientSocket.getInetAddress().getHostAddress();
try
{
inP = new
InputStreamReader(clientSocket.getInputStream());
in = new BufferedReader(inP);
out = new
PrintWriter(clientSocket.getOutputStream(), true);
SAXBuilder builder = new SAXBuilder();
Document doc;
String inputLine;
int streamResult, i;
char buf[] = new char[1];
do{
inputLine = "";
do{
streamResult = in.read(buf,0,1);
if(buf[0] !='\u0000'){
inputLine += buf[0];
}
} while (buf[0] !='\u0000');
if (inputLine.length() > 1) {
try{
doc = builder.build(new
StringReader(inputLine));
flashServ.disburse(doc);
} catch (Exception e) {
e.printStackTrace();
}
}
} while(true);
} catch (Exception e) {
}
}
// Prints XML String
public void send(Document message) {
try{
XMLOutputter outputter = new XMLOutputter();
outputter.output(message,out);
} catch (Exception e){
e.printStackTrace();
}
}
}
Thanks in advance,
Scott
More information about the jdom-interest
mailing list