文件中写字
2013-11-21 12:54
218 查看
//文件中写字
public class FilePrintWriter {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String path = "E:/Dev/Works/JavaUtils/file";
try {
File f1 = new File(path + "/3.txt");
if (!f1.exists()) {
f1.createNewFile(); // 创建
}
PrintWriter pw = new PrintWriter(new FileWriter(f1));
pw.print("123");
pw.close();
FileOutputStream outputStream = new FileOutputStream(f1);
outputStream.write("\ntest".getBytes());
outputStream.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
public class FilePrintWriter {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String path = "E:/Dev/Works/JavaUtils/file";
try {
File f1 = new File(path + "/3.txt");
if (!f1.exists()) {
f1.createNewFile(); // 创建
}
PrintWriter pw = new PrintWriter(new FileWriter(f1));
pw.print("123");
pw.close();
FileOutputStream outputStream = new FileOutputStream(f1);
outputStream.write("\ntest".getBytes());
outputStream.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
相关文章推荐
- OSI七层模型的功能及协议
- 360浏览器强改主页
- Java中split的用法
- restlet中如何返回json和xml类型数据
- 更改SSHSecureShellClient界面大小
- 写入显存 显示hello word
- Handler 机制初步(一)
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- 一个死循环程序无法重定向的问题?linux
- [LeetCode] Linked List Cycle, Solution
- AS3的Vector的初始化
- C++ 默认成员函数、运算符重载 code
- 图像检索:几种基于纹理特征的图像检索算法
- 图像检索:几种基于纹理特征的图像检索算法
- 图像检索:几种基于纹理特征的图像检索算法
- 长寿的树
- mac下MySQL、MysqL workbench的安装与配置配置
- 李撒如图究竟是个什么东西——Lissajous curve
- Freemarker中使用中括号来包含标签
- android 上中下布局,中间自适应