If I want to read ahead a byte,and push it back if it is not '<',I can do it like this:
PushbackInputStream pbin=new PushbackInputStream(new FileInputStream("1.dat"));
int b = pbin.read();
if(b!='<')
pbin.unread(b);
But if I want to push back a double that I read from DataInputStream,what shall i do? For example:
PushbackInputStream pbin1=null;
DataInputStream din=new DataInputStream(
pbin1=new PushbackInputStream(
new FileInputStream("1.dat")
)
);
double d = din.readDouble();
pbin1.unread(d);
The last line pbin1.unread(d);
can not be compiled,because the PushbackInputStream can not push back a double,how can I convent the double to byte array?or any other way?