byte 转file

String filepath="D:\\"+getName();
          File file=new File(filepath);
          if(file.exists()){
              file.delete();
          }
          FileOutputStream fos = new FileOutputStream(file);   
          fos.write(data,0,data,.length);   
          fos.flush();   
          fos.close();

file转 byte

FileInputStream inputStream = new FileInputStream(file);
        ByteArrayOutputStream bytestream = new ByteArrayOutputStream();  
        int ch;  
        while ((ch = inputStream.read()) != -1) {  
         bytestream.write(ch);  
        }  
        byte[] data= bytestream.toByteArray();  
        bytestream.close();  
        inputStream.close();    
        return data;

file与 byte[] 互转的更多相关文章

  1. 字符串string和内存流MemoryStream及比特数组byte[]互转

    原文:字符串string和内存流MemoryStream及比特数组byte[]互转   字符串string和内存流MemoryStream及比特数组byte[]互转比较 定义string变量为str, ...

  2. File to byte[] in Java

    File to byte[] in Java - Stack Overflow https://stackoverflow.com/questions/858980/file-to-byte-in-j ...

  3. Go语言网络通信---string与int互转,int64与[]byte互转,int直接互转,string与[]byte互转

    string与int互转 #string到int int,err:=strconv.Atoi(string) #string到int64 int64, err := strconv.ParseInt( ...

  4. byte数组和File,InputStream互转

    1.将File.FileInputStream 转换为byte数组: File file = new File("file.txt"); InputStream input = n ...

  5. JAVA File转Byte[]

    /** * 获得指定文件的byte数组 */ public static byte[] getBytes(String filePath){ byte[] buffer = null; try { F ...

  6. File和byte[]转换

    http://blog.csdn.net/commonslok/article/details/9493531 public static byte[] File2byte(String filePa ...

  7. inputStream、File、Byte、String等等之间的相互转换

    一:inputStream转换 1.inputStream转为byte //方法一 org.apache.commons.io.IOUtils包下的实现(建议) IOUtils.toByteArray ...

  8. 转转转--Java File和byte数据之间的转换

    package cn.iworker.file; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; ...

  9. java File和Byte[]数组 相互转换

    public class Test { public static void main(String[] args){ String filePath = "E:\\softoon\\wor ...

随机推荐

  1. 关于禁止Android scrollView 因内容变化而自动滚动 android:descendantFocusability

    出现这种情况是因为你让scrollview获得了焦点,所以它才会滚动.如果你百度了以后,你可能会发现有些博客会说让焦点停在固定的一个view中就可以了.这对于不存在刷新的页面确实是可以的,但是当你出现 ...

  2. 关于删除7z历史解压路径

    目前7zip尚无此功能,只能从注册表入手了,7zip历史记录保存在注册表 HKEY_CURRENT_USER\Software\7-Zip\FM 下的CopyHistory和FolderHistory ...

  3. IIS 之 HTTP Error 404.2 – Not Found(ISAPI 和 CGI 限制)

    对于很多B/S架构的软件来说,在IIS中添加ISAPI和CGI限制功能是非常必要的,因为如果在IIS中不添加添加ISAPI和CGI限制功能可能会引起软件运行过程中报错,或者直接就登录不了. 1.允许I ...

  4. 通过cagradientLayer类封装uiimageview动画色度差

    #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, EcolorDirectionType) { EcolorDirectionUp, / ...

  5. java正则表达式常用实例——借鉴思路

    转载自:http://mp.weixin.qq.com/s?__biz=MjM5OTM4NDMyMg==&mid=2650044497&idx=1&sn=dc80fa35f7e ...

  6. ZWave for Arduino

    https://sites.google.com/site/arduinozwave/http://www.ebay.com/sch/i.html?_trksid=p2050601.m570.l131 ...

  7. 四舍五入PK银行四舍五入

    描述 在实际开发中decimal.Round(1.23525,4)!=1.2353实际是1.2352,而decimal.Round(1.23535,4)==1.2354 说明 四舍五入:当舍去位的数值 ...

  8. Mac 在命令行快速切换目录 mark

    转自: http://www.ccvita.com/520.html ,略修改. 每天在命令行下,一大部分的工作都是一遍又一遍的输入 cd ~/some/very/deep/often-used/di ...

  9. FusionCharts Free 注意事项

    前段时间做的项目中用到了FusionCharts Free 这个插件,今天上班打开网站后竟然发现线形图出错了,如图: Y轴都是 NaNM ,经过在网上的一番查询后终于得知为什么了. 原来Free 版本 ...

  10. 干货:Android 源码使用心得分享

          我相信很多初学者会和我一样经常在网上去找Android开发源码,但是往往因为运行不起来非常的懊恼!在做爱开发网站的时候,收集App代码时就遇到了这种困难,我相信网络上面的源码大部分在发布前 ...