BufferedReader|输入输出流BufferedReader PrintWriter demo

//查找建表语句sql导出package huawei; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class TextInput {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new FileReader("D:\\masaa.sql")); PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("D:\\resultFile_a.txt"))); try {String ss = ""; boolean temp = false; while ((ss = br.readLine()) != null) {ss = ss.toUpperCase(); if (ss.indexOf("CREATE TABLE") != -1) {temp = true; }if (temp) {if (ss.trim().indexOf(")") == 0) {temp = false; pw.println("); "); System.out.println("); "); } else {pw.println(ss); System.out.println(ss); }}}pw.flush(); } catch (Exception e) {e.printStackTrace(); } finally {if (br != null) {br.close(); }if (pw != null) {pw.close(); }}}}

    推荐阅读