jsp生成和读取文件
来源:互联网 发布:d在c语言中是什么意思 编辑:程序博客网 时间:2024/06/02 06:47
package news;
import java.io.*;
public class Test11 {
private static BufferedReader br = null;
private static File file = null;
private static BufferedWriter bw = null;
public static void main(String[] args) {
String b = null;
//file = new File("D:\\abc.txt");
file = new File("C:\\Users\\ye\\Desktop\\news\\bb.txt");
System.out.println(file.getAbsolutePath());
//System.out.println(file.getPath());
String path = file.getAbsolutePath();
String[] sb = path.split("\\\\");
for (String string : sb) {
System.out.println(string);
}
if (!file.exists() != false) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
bw = new BufferedWriter(new FileWriter(file));
FileReader fr = new FileReader("C:\\Users\\ye\\Desktop\\news\\aa.txt");
br = new BufferedReader(fr);
while ((b = br.readLine()) != null) {
b= new String(b.getBytes("utf-8"),"utf-8");
System.out.println(b);
bw.write(b);//输出字符串
bw.newLine();//换行
bw.flush();
}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
br.close();
//bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.io.*;
public class Test11 {
private static BufferedReader br = null;
private static File file = null;
private static BufferedWriter bw = null;
public static void main(String[] args) {
String b = null;
//file = new File("D:\\abc.txt");
file = new File("C:\\Users\\ye\\Desktop\\news\\bb.txt");
System.out.println(file.getAbsolutePath());
//System.out.println(file.getPath());
String path = file.getAbsolutePath();
String[] sb = path.split("\\\\");
for (String string : sb) {
System.out.println(string);
}
if (!file.exists() != false) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
bw = new BufferedWriter(new FileWriter(file));
FileReader fr = new FileReader("C:\\Users\\ye\\Desktop\\news\\aa.txt");
br = new BufferedReader(fr);
while ((b = br.readLine()) != null) {
b= new String(b.getBytes("utf-8"),"utf-8");
System.out.println(b);
bw.write(b);//输出字符串
bw.newLine();//换行
bw.flush();
}
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
br.close();
//bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
0 0
- jsp生成和读取文件
- jsp通过javaBean读取和写入文件
- jsp读取大对象CLOB并生成xml文件示例
- jsp读取大对象CLOB并生成xml文件示例
- 使用PHPExcel生成和读取Excel文件
- 使用PHPExcel生成和读取Excel文件
- 使用PHPExcel生成和读取Excel文件
- 使用PHPExcel生成和读取Excel文件
- 使用PHPExcel生成和读取Excel文件
- C# API: 生成和读取Excel文件
- 【C++】JSON文件的读取和生成
- 【C++】JSON文件的读取和生成
- 【C++】JSON文件的读取和生成
- 【C++】JSON文件的读取和生成
- python读取和生成excel文件
- TFRecords 文件的生成和读取
- jsp文件操作:读取和写入文件的方法
- JSP读取客户端文件
- 黑马程序员_OC学习之类的深入研究
- THE DRUNK JAILER - POJ 1218 水题
- 现在公开一个DHT网络爬虫网络爬虫供大家一起交流
- 利用DHT网络原理制作bt采集蜘蛛,开源版
- 现在公开一个DHT网络爬虫网络爬虫供大家一起交流
- jsp生成和读取文件
- 【学习并改进】黑马程序员-张孝祥-交通灯管理系统业务
- 上拉电阻、下拉电阻的原理和作用
- 黑马程序员————java7K高薪——银行业务调试系统
- 搭建coreseek(sphinx+mmseg3)详细安装配置+php之sphinx扩展安装+php调用示例
- 选择排序
- C++单链表的操作(创建,删除,打印,遍历,插入)
- 《商战之电商风云》观后感
- 黑马程序员_set方法内存管理