从文件获取源代码
//package com.nowjava;/* from n o w j a v a . c o m*/ import java.io.*; public class Main { public static void main(String[] argv) throws Exception { File file = new File("Main.java"); System.out.println(getSourceCodeFromFile(file)); } public static String getSourceCodeFromFile(File file) { String sourceCode = ""; if (file == null) { return sourceCode;/*来自 时 代 Java - nowjava.com*/ } try { Reader reader = new FileReader(file); sourceCode = getString(reader); } catch (IOException e) { throw new RuntimeException(e); } return sourceCode; } private static String getString(Reader reader) throws IOException { String text = ""; BufferedReader bufferedReader =