Re: How to parse and manipulate a binary stream
- From: Mark Jeffcoat <jeffcoat@xxxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 22:27:24 GMT
"topcat.nyc@xxxxxxxxxxxxxx" <topcat.nyc@xxxxxxxxxxxxxx> writes:
Apologies in advance if my question is silly or trivial. I'm trying to
write a servlet that reads data from another source in byte[] form and,
having parsed this data stream and made a couple of modifications,
sends the modified data to an appropriate application whereby it can be
rendered in Excel or PDF format.
What I need to find out is how I can parse the incoming data, detect
certain string patterns in the data, and manipulate that information to
generate a new data stream.
Not a trivial question, exactly, but a bit on the
vague side. It's difficult for me to tell what you're
having difficultly with.
I'm going to assume that you're stuck getting started.
First, you need to read binary data from a source. That's
exactly the job of an InputStream. It has a read() method
that lets to read directly into a byte array.
To parse that a portion of a byte[] as a String, you can
just use the constructors in the String class.
To write the output, you need an OutputStream. You may want
to subclass it, and write a write() that asks for its next
byte of output from the object responsible for doing the
search-and-replace manipulation.
--
Mark Jeffcoat
Austin, TX
.
- References:
- How to parse and manipulate a binary stream
- From: topcat.nyc@xxxxxxxxxxxxxx
- How to parse and manipulate a binary stream
- Prev by Date: Re: How to update a jar file for one source file change?
- Next by Date: JAVA Time Problem: Want to get the current time and perform validation
- Previous by thread: How to parse and manipulate a binary stream
- Next by thread: xsl document() function - java SimpleTransform cannot find file
- Index(es):
Relevant Pages
|