IO
来源:互联网 发布:杜尔清洗机编程 编辑:程序博客网 时间:2024/06/05 13:33
其实对于工作流来说,只要会这一个.学会了.基本上就学会了..所谓万变不离其宗..对于文件操作一说.读写其实是最简单的..对读取出来的数据进行分析才是我们需要针对项目加大精力的事情..
package wsc.com.it;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class IOTest {
// 针对初学者掌握IO
public static void main(String[] args) throws IOException {
// 读取文件
int b = 0;
FileInputStream in = null;
try {
in = new FileInputStream("test.xml");
} catch (FileNotFoundException e) {
System.out.println("找不到指定文件");
System.exit(-1);
}
try {
long num = 0;
while ((b = in.read()) != -1) {
System.out.print((char) b);
num++;
}
in.close();
System.out.println();
System.out.println("共读取了" + num + "个字节");
} catch (IOException e1) {
System.out.println("文件读取出错");
System.exit(-1);
}
// 写文件
int b1 = 0;
FileInputStream in1 = null;
FileOutputStream out = null;
try {
in1 = new FileInputStream("test.xml");
out = new FileOutputStream("test.txt");
while ((b1 = in1.read()) != -1) {
out.write(b1);
}
in1.close();
out.close();
} catch (FileNotFoundException e2) {
System.out.println("找不到指定文件");
System.exit(-1);
} catch (IOException e1) {
System.out.println("文件复制出错");
System.exit(-1);
}
System.out.println("文件已复制");
}
}
- IO
- IO
- io
- IO
- io
- IO
- io
- IO
- IO
- IO
- io
- IO
- IO
- IO
- IO
- IO
- IO
- IO
- redis-cli 命令总结
- AWR报告(二)--读懂AWR--10G
- 关于eclipse中R.java不生成的问题
- 概率dp-poj-2096-Collecting Bugs
- Java7中的switch支持String的实现细节
- IO
- SDN学习笔记
- 使用WampServer搭建本地PHP环境,绑定域名,配置伪静态
- 题目1514:数值的整数次方-九度
- [leetcode刷题系列]Decode Ways
- Linux驱动修炼之道-INPUT子系统(上)
- 卒仔抽车
- 使用Java动态代理实现的拦截器
- 全国省市数据库