import java.io.*; class Generate { public static void main(String[] args) throws Exception { double secsPerChar = 0, errorPercent = 0; String s; int i, j, lessonNumber = 0, lineNumber = -1; BufferedReader in = null; BufferedWriter out = null; if (args.length != 1) { System.err.println("使い方: java Generate 入力ファイル"); System.exit(0); } in = new BufferedReader(new FileReader(args[0])); while ((s = in.readLine()) != null) { if (s.startsWith(";")) continue; if (s.startsWith("#")) { if (out != null) { if (lineNumber >= 0) { out.write(""); out.newLine(); lineNumber = -1; } out.write("
"); out.newLine(); out.write("

"); out.newLine(); out.write("" + "目次"); out.newLine(); if (lessonNumber > 0) { out.write("" + "戻る"); out.newLine(); } out.write("進む"); out.newLine(); out.close(); out = null; } lessonNumber++; lineNumber = -1; out = new BufferedWriter(new FileWriter(lessonNumber + ".html")); i = 1; while (i < s.length() && s.charAt(i) <= ' ') i++; j = i; while (j < s.length() && s.charAt(j) > ' ') j++; secsPerChar = Double.valueOf(s.substring(i, j)).doubleValue(); i = j; while (i < s.length() && s.charAt(i) <= ' ') i++; j = i; while (j < s.length() && s.charAt(j) > ' ') j++; errorPercent = Double.valueOf(s.substring(i, j)).doubleValue(); out.write("第" + lessonNumber + "課"); out.newLine(); out.write(""); out.newLine(); out.write("

第" + lessonNumber + "課

"); out.newLine(); out.newLine(); } else if (s.length() != 0 && s.charAt(0) == '\t') { if (lineNumber == -1) { out.write("

"); out.newLine(); out.write(""); out.newLine(); out.write(""); out.newLine(); out.write(""); out.newLine(); } out.write(""); out.newLine(); } else { if (lineNumber >= 0) { out.write(""); out.newLine(); lineNumber = -1; } out.write(s); out.newLine(); } } if (out != null) { out.write("


"); out.newLine(); out.write("

"); out.newLine(); out.write("" + "目次"); out.newLine(); if (lessonNumber > 0) { out.write("戻る"); out.newLine(); } out.close(); out = null; } } }