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. C#获取进程的主窗口句柄的实现方法

    通过调用Win32 API实现. public class User32API { private static Hashtable processWnd = null; public delegat ...

  2. Remoting

    一.      Remoting基础 什么是Remoting,简而言之,我们可以将其看作是一种分布式处理方式.从微软的产品角度来看,可以说Remoting就是DCOM的一种升级,它改善了很多功能,并极 ...

  3. SQL Server 中的事务和锁(三)-Range S-U,X-X 以及死锁

    在上一篇中忘记了一个细节.Range T-K 到底代表了什么?Range T-K Lock 代表了在 SERIALIZABLE 隔离级别中,为了保护范围内的数据不被并发的事务影响而使用的一类锁模式(避 ...

  4. 《Cortex-M0权威指南》之体系结构---嵌套中断控制器(NVIC)

    转载请注明来源:cuixiaolei的技术博客 为了管理中断请求的优先级并处理其他异常,Cortex-M0处理器内置了嵌套中断控制器(NVIC).NVIC的一些可编程控制器控制着中断管理功能,这些寄存 ...

  5. iphone开发之用lipo合并模拟器库和真机库,发布一个通用的静态库

    转载自:http://blog.csdn.net/arthurchenjs/article/details/6044616 lipo lipo –create Release-iphoneos/lib ...

  6. 【原创】C++链表如何像Python List一样支持多种数据类型

    用过Python的码友都知道,Python中List支持多种数据类型,如下面代码所示链表li内的数据类型可以是整数,同时也可以是字符串,当然也可以是其他数据类型. 1: >>> li ...

  7. 管理后台-第二部分:Custom sections in Umbraco 7 – Part 2 the views(翻译文档)

    在上一篇文章中我们讨论了怎样在我们Umbraco7.0版本中去添加一个新的自定义的应用程序(或部分)和如何去定义一个树.现在我将给你展示你改何如添加视图,来使你的内容可以做一些更有意义的事情. The ...

  8. ionic 项目的启动屏幕

    首先要做好图片,图片的大小最好是192px*192px(icon.png).2208px*2208px(splash.png); 然后在APP项目中建立一个新文件夹,resources,将准备好的两张 ...

  9. vc如何编译链接opengl库

    强烈推荐的一篇强大的OpenGl学习博文OpenGL入门学习 vc2012如何链接opengl库? 首先,我们需要下载opengl的库文件,http://pan.baidu.com/s/1kTsjkZ ...

  10. Common工具类的验证码类的使用(未实现验证)

    验证码接收 using System; using System.Collections.Generic; using System.Linq; using System.Web; using CZB ...