博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java用FileReader和FileWrite读取和写入字符
阅读量:4029 次
发布时间:2019-05-24

本文共 582 字,大约阅读时间需要 1 分钟。

package imcoo.com;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import jdk.jfr.events.FileWriteEvent;
public class frAndfwDame {
/**
* @param args
*/
public static void main(String[] args)throws IOException {
// TODO Auto-generated method stub
FileReader fr =new FileReader("C:\\Users\\Hano\\Desktop\\123.txt");
FileWriter fw=new FileWriter("C:\\Users\\Hano\\Desktop\\1234.txt");
char []buffer =new char [1024];
int c;
while((c=fr.read(buffer,0,buffer.length))!=-1){
fw.write(buffer,0,c);
}
fw.close();
}
}

说明:使用FileReader比较简单,但是时只能是默认的编码方式“gbk”

转载地址:http://rdlbi.baihongyu.com/

你可能感兴趣的文章
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]107. Binary Tree Level Order Traversal II
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
[LeetCode By Python]167. Two Sum II - Input array is sorted
查看>>
[LeetCode BY Python]169. Majority Element
查看>>
[LeetCode By Python]172. Factorial Trailing Zeroes
查看>>
[LeetCode By MYSQL] Combine Two Tables
查看>>
python jieba分词模块的基本用法
查看>>
[CCF BY C++]2017.12 最小差值
查看>>