// 断点不存在或出现错误则返回backup private static int GetBreakPoint(String bpFile, int backup) { FileReader fr = null; try { fr = new FileReader(bpFile); BufferedReader br = new BufferedReader(fr); String numStr = br.readLine(); return Integer.parseInt(numStr); } catch (NumberFormatException | IOException e) { return backup; } finally { try { if (fr != null) { fr.close(); } } catch (IOException e) { e.printStackTrace(); } } } private static void SetBreakPoint(String bpFile, int num) throws FileNotFoundException { PrintStream f = new PrintStream(bpFile); f.println(num); f.close(); } private static void DelBreakPoint(String bpFile) { File f = new File(bpFile); if (f.exists()) { f.delete(); } } |
|