Link to home
Start Free TrialLog in
Avatar of nirupamc
nirupamc

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of libin_v
libin_v
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ajay-Singh
Ajay-Singh

have a question, before I suggest a solution, What is type of message? Java serialized object? or some other type
2.
Avatar of nirupamc

ASKER


This is an xml message via a workflow which comes as a standard in to the program that I am working on