@Test public void testCheckFileSize() throws IOException { for (int i = 0; i < 5; i++) { String content = "hello,world"; if (i == 1) { content = "hello,liangyf"; } File file = new File(fileName); FileUtils.writeStringToFile(file, content); BadOperateWriter.checkFileSize(fileName, 1); Assert.assertFalse(file.exists()); String fileContent = FileUtils.readFileToString(new File(fileName + ".bak")); Assert.assertEquals(fileContent, content); } }
public static void checkFileSize(String fileName, int maxFileSize) { File file = new File(fileName); if (file.exists() && file.length() > maxFileSize) { String bakFileName = fileName + ".bak"; File bakFile = new File(bakFileName); file.renameTo(new File(bakFile.getAbsolutePath())); } }
BadOperateWriter { public static void checkFileSize(String fileName, int maxFileSize) { File file = new File(fileName); if (file.exists() && file.length() > maxFileSize) { String bakFileName = fileName + ".bak"; File bakFile = new File(bakFileName); file.renameTo(new File(bakFile.getAbsolutePath())); } } }
BadOperateWriter { public static void checkFileSize(String fileName, int maxFileSize) { File file = new File(fileName); if (file.exists() && file.length() > maxFileSize) { String bakFileName = fileName + ".bak"; File bakFile = new File(bakFileName); file.renameTo(new File(bakFile.getAbsolutePath())); } }  }
BadOperateWriter { public static void checkFileSize(String fileName, int maxFileSize) { File file = new File(fileName); if (file.exists() && file.length() > maxFileSize) { String bakFileName = fileName + ".bak"; File bakFile = new File(bakFileName); file.renameTo(new File(bakFile.getAbsolutePath())); } }  static void checkFileSize(String fileName, int maxFileSize); static void write(Op op, String oracleFullTableName, String topicName, String fileName,
                             int maxFileSize, String msg); static void write(RecordEntry recordEntry, String oracleFullTableName, String topicName,
                             String fileName, int maxFileSize, String msg); }
BadOperateWriter { public static void checkFileSize(String fileName, int maxFileSize) { File file = new File(fileName); if (file.exists() && file.length() > maxFileSize) { String bakFileName = fileName + ".bak"; File bakFile = new File(bakFileName); file.renameTo(new File(bakFile.getAbsolutePath())); } }  static void checkFileSize(String fileName, int maxFileSize); static void write(Op op, String oracleFullTableName, String topicName, String fileName,
                             int maxFileSize, String msg); static void write(RecordEntry recordEntry, String oracleFullTableName, String topicName,
                             String fileName, int maxFileSize, String msg);  }