I'm writing a byte[] to file and read it. But why the byte[] is different between write and read? Here is my code:
import java.io.*;
public class test{
public static void main(String argv[]){
try{
byte[] Write = "1234567812345678".getBytes();
byte[] Read = new byte[16];
File test_file = new File("test_file");
test_file.mkdir();
String path = new String(test_file.getAbsolutePath()+"\\"+"test.txt");
File test_out = new File(path);
test_out.createNewFile();
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(test_out));
out.write(Write);
out.close();
File test_in = new File(path);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(test_in));
while(in.available()>0)
in.read(Read);
in.close();
System.out.println(Write);
System.out.println(Read);
}catch ( Exception e ){
e.printStackTrace();
}
}
}
And here is the output; the input and output are different:
[B@139a55
[B@1db9742