FileOutputStream中的 3种write方式
2015-08-05 19:18
726 查看
第一步:搭好 程序Output到文件 的管道
FileOutputStream fos = new FileOutputStream("B.txt");//如果没有fos2.txt文件则会自动创建这个文件
第二步:写入数据 到管道
//方式一:int oneByte
fos.write(1);
//方式二 byte[
] bufferArr public void write(byte[] b):写一个字节数组
byte[] bys = {1,2,3,4,5};
fos.write(bys);
//方式三 //public
void write(byte[] b,int off,int len)
fos.write(bys,1,3); //将 2,3,4写入文件
第三步:关闭管道,释放资源
fos.close();
方式三解释
public void write(byte[ ]
bufferArr, int byteOffset, int byteCount) throws IOException {
}
。。。OutputStream.write()。。
clientSocket.getOutputStream().write(buff, 0, cbRead);//从buff中读取0~cbRead数据存入OutputStream.
。。。InputStream.read()。。。。
int cbRead = data.read(buff, 0, buff.length);//从data中读取0~buff.length数据存入buff.
....
FileOutputStream fos = new FileOutputStream("B.txt");//如果没有fos2.txt文件则会自动创建这个文件
第二步:写入数据 到管道
//方式一:int oneByte
fos.write(1);
//方式二 byte[
] bufferArr public void write(byte[] b):写一个字节数组
byte[] bys = {1,2,3,4,5};
fos.write(bys);
//方式三 //public
void write(byte[] b,int off,int len)
fos.write(bys,1,3); //将 2,3,4写入文件
第三步:关闭管道,释放资源
fos.close();
方式三解释
public void write(byte[ ]
bufferArr, int byteOffset, int byteCount) throws IOException {
}
。。。OutputStream.write()。。
clientSocket.getOutputStream().write(buff, 0, cbRead);//从buff中读取0~cbRead数据存入OutputStream.
。。。InputStream.read()。。。。
int cbRead = data.read(buff, 0, buff.length);//从data中读取0~buff.length数据存入buff.
....
相关文章推荐
- zendframework form with captcha(Base on ZendFrameWork2.4)
- php实现分页调取数据库记录
- zend 环境
- 5种php加密工具zendGuard、ionCube、SourceCop、SourceGuardian、phpShield
- yii 时间控件 输入框
- 发送邮件(遵循smtp协议即简单的邮件发送协议)
- php数组
- php字符串
- 关系:CGI,FastCGI,PHP-CGI与PHP-FPM
- 概念:CGI,FastCGI,PHP-CGI与PHP-FPM
- php异常处理
- 以源码编译的方式安装PHP与php-fpm
- PHP array系列函数
- thinkphp 整合swfupload
- PHP关联数组的10个操作技巧
- php 学习,自己看
- php mysql注入攻击解决方案
- php mysql 事务 锁 小计
- HessianPHP使用注意事项
- php 等比例生成缩略图