• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 816
  • Last Modified:

Peek a stream message in java

I need to peek a stream message to do some processing. This needs to be done before reading the whole message

I have the current code


inputStream = new BufferedInputStream(System.in, 1024);
 
FileOutputStream fos = new FileOutputStream(convTempFileName);
 
byte[] buf = new byte[256];
 
int read = 0;
 
while ((read = inputStream.read(buf)) > 0) {
 
// Here I need to dos omething when I see some particular element in the message
 
fos.write(buf, 0, read);
 
}
 
fos.close();

Open in new window

0
nirupamc
Asked:
nirupamc
1 Solution
 
libin_vCommented:
0
 
Ajay-SinghCommented:
have a question, before I suggest a solution, What is type of message? Java serialized object? or some other type
2.
0
 
nirupamcAuthor Commented:

This is an xml message via a workflow which comes as a standard in to the program that I am working on
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now