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-03-22 10:55:29

    box-shadow四个边框设置阴影样式

    其实对于box-shadow,老白我也是一知半解,之前用的时候直接复制已有的,也没有仔细思考过box-shadow的数值分别对应什么,最后导致阴影的边如何自由控制,苦于懒人一个一直没有正式去学习,今天无意中看到以下这篇文章,瞬间清醒有木有,看完整片文章,对于box-shadow阴影四个边的设置完全了如指掌了,再也不怕修改box-shadow了!

  • 2021-04-06 17:13:08

    nuxt.js keep-alive和嵌套路由不变化

    因为你错误的使用了 <nuxt>标签。 你应该使用 <nuxt-child keep-alive > </nuxt-child> 因为上层已经使用过了 <nuxt></nuxt>标签。