程序如下:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
public class Text7 {
public static void main(String[] args) {
String inpath = "c:\\lowertest.txt";
String outpath = "c:\\uppertest.txt";
String str = "";
try {
File infile = new File(inpath);
BufferedReader reader = new BufferedReader(new FileReader(infile));
String i = null;
while ((i = reader.readLine()) != null) {
str += i;
}
reader.close();
File outfile = new File(outpath);
if (!outfile.exists()) {
outfile.createNewFile();
}
FileWriter fw = new FileWriter(outfile.getAbsoluteFile());
BufferedWriter bufferWritter = new BufferedWriter(fw);
bufferWritter.write(str.toUpperCase());
bufferWritter.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
不知是否帮到你,若满意请采纳!