
{filelink=351}
/***** Code de MesExemples.com *******/
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PushbackInputStream;
class ExemplePushbackInputStreamEnJava {
public static void main(String[] args)
{
String strExpression = "a = a++ + b;";
byte bytes[] = strExpression.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
PushbackInputStream pis = new PushbackInputStream(bis);
int ch;
try
{
/* Lecture des opérateurs + en priorité */
while( (ch = pis.read())!= -1)
{
if(ch == '+')
{
if( (ch = pis.read()) == '+')
{
System.out.print("Plus Plus");
}
else
{
pis.unread(ch);
System.out.print("+");
}
}
else
{
System.out.print((char)ch);
}
}
}
catch(IOException ioe)
{
System.out.println("Exception de lecture stream" + ioe);
}
}
}