JAVA-19534 Cleanup un-committed or un-ignored artifacts - Week 14 - 2023 (#13695)
Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
@@ -7,12 +7,14 @@ public class DataStream {
|
||||
PrintStream out = new PrintStream(fileName);
|
||||
out.print(content);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void textDataProcessingCharStream(String fileName, String content) throws IOException {
|
||||
PrintWriter out = new PrintWriter(fileName);
|
||||
out.print(content);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void nonTextDataProcessing(String fileName, String streamOutputFile, String writerOutputFile) throws IOException {
|
||||
@@ -33,5 +35,6 @@ public class DataStream {
|
||||
writer.write(c);
|
||||
}
|
||||
writer.close();
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
@@ -23,32 +23,29 @@ public class DataStreamUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenUsingByteStream_thenWriteTextToFile() throws IOException {
|
||||
DataStream dataStream = new DataStream();
|
||||
dataStream.textDataProcessingByteStream(dataProcessingTextFile, textFileContent);
|
||||
DataStream.textDataProcessingByteStream(dataProcessingTextFile, textFileContent);
|
||||
|
||||
File file = new File(dataProcessingTextFile);
|
||||
assertTrue(file.exists());
|
||||
assertEquals(textFileContent, FileUtils.readFileToString(file, "utf-8"));
|
||||
|
||||
Files.delete(Paths.get(dataProcessingTextFile));
|
||||
Files.deleteIfExists(Paths.get(dataProcessingTextFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingCharStream_thenWriteTextToFile() throws IOException {
|
||||
DataStream dataStream = new DataStream();
|
||||
dataStream.textDataProcessingCharStream(dataProcessingTextFile, textFileContent);
|
||||
DataStream.textDataProcessingCharStream(dataProcessingTextFile, textFileContent);
|
||||
|
||||
File file = new File(dataProcessingTextFile);
|
||||
assertTrue(file.exists());
|
||||
assertEquals(textFileContent, FileUtils.readFileToString(file, "utf-8"));
|
||||
|
||||
Files.delete(Paths.get(dataProcessingTextFile));
|
||||
Files.deleteIfExists(Paths.get(dataProcessingTextFile));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingStreams_thenWriteNonTextData() throws IOException {
|
||||
DataStream dataStream = new DataStream();
|
||||
dataStream.nonTextDataProcessing(dataProcessingImageFile, dataProcessingByteStreamFile, dataProcessingCharStreamFile);
|
||||
DataStream.nonTextDataProcessing(dataProcessingImageFile, dataProcessingByteStreamFile, dataProcessingCharStreamFile);
|
||||
|
||||
File file = new File(dataProcessingImageFile);
|
||||
File byteStreamOutputFile = new File(dataProcessingByteStreamFile);
|
||||
@@ -60,7 +57,7 @@ public class DataStreamUnitTest {
|
||||
assertTrue(FileUtils.contentEquals(file, byteStreamOutputFile));
|
||||
assertFalse(FileUtils.contentEquals(file, charStreamOutputFile));
|
||||
|
||||
Files.delete(Paths.get(dataProcessingByteStreamFile));
|
||||
Files.delete(Paths.get(dataProcessingCharStreamFile));
|
||||
Files.deleteIfExists(Paths.get(dataProcessingByteStreamFile));
|
||||
Files.deleteIfExists(Paths.get(dataProcessingCharStreamFile));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user