This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Writing xml data to file from TCP port Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Writing xml data to file from TCP port" Watch "Writing xml data to file from TCP port" New topic
Author

Writing xml data to file from TCP port

Alan So
Greenhorn

Joined: Sep 07, 2011
Posts: 10
Hi,

Currently my program code is listening to TCP port and I will be receiviing XML data and the data will be save to a file.

The issue is that the XML data contains the respond data from the server whenever it send back to the client, how can I get rid of the respond data.

Example,

respond=ok;blah blah
<xml>
......
......
</xml>

if there are two responds... it will be

respond=ok;blah blah
<xml>
......
......
</xml>
respond=ok;blah blah
<xml>
......
......
</xml>


So I do not want to write the "respond=ok;blah blah" to the xml file. Because once I write that to a file, it will not be in a XML format. Please advice on how can I read the XML data from the TCP port correctly and save it to a file. Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Read parts of the data in advance (perhaps one line at a time), and only start writing once you've encountered the XML start.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing xml data to file from TCP port
 
Similar Threads
text files creation
Nested Map
file
XML over http
Correct Generated File Extensions from Action