将文件中的所有文本转换为大写字符
/** 时代Java公众号 - N o w J a v a . c o m 提 供 **/ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void main(String[] arguments) { String sourceName = "a.txt"; try {/*from NowJava.com*/ Path source = FileSystems.getDefault().getPath(sourceName); Path temp = FileSystems.getDefault().getPath("tmp_" + sourceName); // Create input stream FileReader fr = new FileReader(source.toFile()); BufferedReader in = new BufferedReader(fr); // Create output stream FileWriter fw = new FileWriter(temp.toFile()); BufferedWriter out = new BufferedWriter(fw); boolean eof = false; int inChar; do { inChar = in.read(); if (inChar != -1) { char outChar = Character.toUpperCase((char) inChar); out.write(outChar); } else eof = true;