byte数组和File,InputStream互转

2019-09-02 01:15:22


 byte数组和File,InputStream互转

1、将File、FileInputStream 转换为byte数组:
 
    File file = new File("file.txt");
 
    InputStream input = new FileInputStream(file);
 
    byte[] byt = new byte[input.available()];
 
    input.read(byt);
 
 
 
2、将byte数组转换为InputStream:
 
    byte[] byt = new byte[1024];
 
    InputStream input = new ByteArrayInputStream(byt);
 
 
 
3、将byte数组转换为File:
 
    File file = new File('');
 
    OutputStream output = new FileOutputStream(file);
 
    BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
 
    bufferedOutput.write(byt);


  • 2021-11-03 19:59:58

    Android 11 adb无线调试使用方法

    ​Android 11无线调试不需要再像以前一样,先插上usb线,输入命令来启用无线调试,再进行无线连接了。Android 11系统设置开发者选项中自带了无线调试,今天亲自测试了