Difficulties with using DataInputStream and DataOutputStream

Hello all,

I need help for understanding what I'm doing wrong here:

(pass and user are byte[] encrypted with RSA) the problem is that i can;t read what i wrote. :(

f =new DataOutputStream (new FileOutputStream("file.txt"));

f.write(pass);

f.write(user);

f.flush();

f.close();

System.out.println ("write pass"+pass);

System.out.println ("write user"+user);

f2 =new DataInputStream (new FileInputStream("file.txt"));

System.out.println("Available bytes"+f2.available());

byte [] ru =newbyte[64];

f2.read(ru,0,64);

byte [] rp =newbyte[64];

f2.read(rp);

f2.close();

System.out.println("read user"+ru);

System.out.println("read pass"+rp);

//output

write pass[B@2a4983

write user[B@406199

Available bytes128

read user[B@1b09468

read pass[B@1df5a8f

[1407 byte] By [ShakuR_a] at [2007-11-26 23:37:21]
# 1

So you didn't manage to figure it out for yourself - http://forum.java.sun.com/thread.jspa?threadID=5155256&messageID=9587510#9587510 !

P.S. You need to think more about what you are trying to do and you need to read the Javadoc for DataInputStream and DataOutputStream .

Message was edited by:

sabre150

sabre150a at 2007-7-11 15:00:43 > top of Java-index,Java Essentials,New To Java...
# 2
hehe no sabre but i changed to a 'lower level' forum for not bothering you with my lame questions ;) I guess i failed to this also.Anw thnx
ShakuR_a at 2007-7-11 15:00:43 > top of Java-index,Java Essentials,New To Java...