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);
byte数组和File,InputStream互转的更多相关文章
- InputStream,BufferedImage与byte数组之间的转换
需要获取网络的一张图片,但是某种需要,要把获取的这段流输入换为BufferedImage流,有的地方还需要转换为byte[]. 获得图片地址,获得了一个图片输入流,例如: Url img = n ...
- java byte数组与String互转
java byte数组与String互转 CreationTime--2018年7月6日14点53分 Author:Marydon 1.String-->byte[] 方法:使用String ...
- java File和Byte[]数组 相互转换
public class Test { public static void main(String[] args){ String filePath = "E:\\softoon\\wor ...
- 将文件File转换成byte数组
代码如下: /** * 将文件转换成byte数组 * @param filePath * @return */ public static byte[] File2byte(File tradeFil ...
- Golang十六进制字符串和byte数组互转
Golang十六进制字符串和byte数组互转 需求 Golang十六进制字符串和byte数组互相转换,使用"encoding/hex"包 实现Demo package main i ...
- int跟byte[]数组互转的方法,整数 + 浮点型
整数: int转byte数组 public static byte[] intToBytes2(int n){ ]; ;i < ;i++) { b[i]=(-i*)); } return b; ...
- 字符串、十六进制、byte数组互转
import java.io.ByteArrayOutputStream; public class HexUtil { /** * @param args */ public static void ...
- 二进制样式的字符串与byte数组互转函数示例
开发时用到的方法,记录下: /// <summary> /// 测试方法 /// </summary> private void TestFun() { Response.Wr ...
- 可序列化对象和byte[]数组之间的互转
/// <summary> /// 将可序列化对象转成Byte数组 /// </summary> /// <param name="obj">对 ...
随机推荐
- Asp.Net MVC<三> : ASP.NET MVC 基本原理及项目创建
MVC之前的那点事儿系列 解读ASP.NET 5 & MVC6系列 MVC模拟(摘自ASP.NET MVC5框架揭秘) Asp.net中,通过HttpModule的形式定义拦截器,也就是路由表 ...
- 使用powershell链接到Azure
一:针对传统的的Azure 的登陆界面: (ASM) 1. 正常来说是 现在本地创建证书文件,然后上传文件,以便本地计算机和Azure建立可靠的安全连接 Get-AzurePublishSetting ...
- c++调用lua环境配置
安装完luaforwindows后进行配置 配置项目属性
- 下载imagenet2012数据集
摸索了一下,imagenet2012下载,跟大家分享一下 用迅雷会员加速都可以下载,有的用百度云也可以离线下载 http://www.image-net.org/challenges/LSVRC/20 ...
- Alpha阶段第九次Scrum Meeting
情况简述 Alpha阶段第九次Scrum Meeting 敏捷开发起始时间 2016/11/2 00:00 敏捷开发终止时间 2016/11/3 00:00 会议基本内容摘要 汇报进度,安排工作 参与 ...
- iOS苹果推送功能实现步骤
1.在钥匙串里 导出推送证书Apple Push notification Services 的 certificate, 命名为cer.p12,放在电脑桌面 ,期间密码设为123456 2.在钥匙串 ...
- 安卓贴图源码--->单点触控.多点触控.类似in/百度魔图
效果如图: 类似in,百度魔图,的贴图功能 核心的地方:单/多点 旋转缩放后记录各个顶点小图标位置 引用这里 http://blog.csdn.net/xiaanming/article/detai ...
- [Unity] Shader(着色器)之纹理贴图
在Shader中,我们除了可以设定各种光线处理外,还可以增加纹理贴图. 使用 settexture 命令可以为着色器指定纹理. 示例代码: Shader "Sbin/ff2" { ...
- C语言基础(1)-基本语法及注意事项
1. include 头文件包含 #include <stdio.h>这个是hello world程序的第一句话 # 代表预编译指令 #include的意思就是头文件包含,使用C语言库函数 ...
- Javascript的setTimeOut()和setInterval()的定时器用法
Javascript用来处理延时和定时任务的setTimeOut和setInterval函数应用非常广泛,它们都用来处理延时和定时任务,比如打开网页一段时间后弹出一个登录框,页面每隔一段时间发送异步请 ...