File转byte[]

FileInputStream stream = new FileInputStream(f);   

ByteArrayOutputStream out = new ByteArrayOutputStream(1000);   

byte[] b = new byte[1000];   

 int n;   

while ((n = stream.read(b)) != -1)   

      {   

 out.write(b, 0, n);   

      }   

stream.close();   

out.close();   

 return out.toByteArray(); 

你可能感兴趣的:(Stream,File,byte)