要求是编一个java程序能读txt文档,把文档中的大写字母转化成小写字母,保存在另一个新的文档里结束

辛苦写的,不会有乱码,测试下,行就采纳吧!

package test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Test1 {
public static void main(String[] args) throws IOException {
String txtFilePath = "d:/aaaaa.txt";//原文件
FileInputStream fis = new FileInputStream(new File(txtFilePath));
InputStreamReader isr = new InputStreamReader(fis,"GBK");
BufferedReader reader = new BufferedReader(isr);

String otherTxtFilePath = "d:/test_lower.txt";//保存小写的文件
FileOutputStream fos = new FileOutputStream(new File(otherTxtFilePath));
OutputStreamWriter osw = new OutputStreamWriter(fos,"GBK");
BufferedWriter writer = new BufferedWriter(osw);

String line = null;
while((line = reader.readLine()) != null){
writer.append(line.toLowerCase()).append("\r\n");
}

writer.close();
reader.close();
}
}