|
23 | 23 | import java.io.BufferedOutputStream; |
24 | 24 | import java.io.File; |
25 | 25 | import java.io.FileInputStream; |
26 | | -import java.io.FileOutputStream; |
27 | 26 | import java.io.FileReader; |
28 | 27 | import java.io.FileWriter; |
29 | 28 | import java.io.IOException; |
|
33 | 32 | import java.io.PrintWriter; |
34 | 33 | import java.io.Reader; |
35 | 34 | import java.io.Writer; |
| 35 | +import java.nio.file.Files; |
36 | 36 | import java.util.Arrays; |
37 | 37 |
|
38 | 38 | import org.junit.Before; |
@@ -95,7 +95,7 @@ public void tearDown() |
95 | 95 | private void createFile( File file, long size ) |
96 | 96 | throws IOException |
97 | 97 | { |
98 | | - BufferedOutputStream output = new BufferedOutputStream( new FileOutputStream( file ) ); |
| 98 | + BufferedOutputStream output = new BufferedOutputStream( Files.newOutputStream( file.toPath() ) ); |
99 | 99 |
|
100 | 100 | for ( int i = 0; i < size; i++ ) |
101 | 101 | { |
@@ -161,7 +161,7 @@ public void testInputStreamToOutputStream() |
161 | 161 | { |
162 | 162 | File destination = newFile( "copy1.txt" ); |
163 | 163 | FileInputStream fin = new FileInputStream( testFile ); |
164 | | - FileOutputStream fout = new FileOutputStream( destination ); |
| 164 | + OutputStream fout = Files.newOutputStream( destination.toPath() ); |
165 | 165 |
|
166 | 166 | IOUtil.copy( fin, fout ); |
167 | 167 | assertTrue( "Not all bytes were read", fin.available() == 0 ); |
@@ -212,7 +212,7 @@ public void testReaderToOutputStream() |
212 | 212 | { |
213 | 213 | File destination = newFile( "copy3.txt" ); |
214 | 214 | FileReader fin = new FileReader( testFile ); |
215 | | - FileOutputStream fout = new FileOutputStream( destination ); |
| 215 | + OutputStream fout = Files.newOutputStream( destination.toPath() ); |
216 | 216 | IOUtil.copy( fin, fout ); |
217 | 217 | // Note: this method *does* flush. It is equivalent to: |
218 | 218 | // OutputStreamWriter _out = new OutputStreamWriter(fout); |
@@ -264,7 +264,7 @@ public void testStringToOutputStream() |
264 | 264 | FileReader fin = new FileReader( testFile ); |
265 | 265 | // Create our String. Rely on testReaderToString() to make sure this is valid. |
266 | 266 | String str = IOUtil.toString( fin ); |
267 | | - FileOutputStream fout = new FileOutputStream( destination ); |
| 267 | + OutputStream fout = Files.newOutputStream( destination.toPath() ); |
268 | 268 | IOUtil.copy( str, fout ); |
269 | 269 | // Note: this method *does* flush. It is equivalent to: |
270 | 270 | // OutputStreamWriter _out = new OutputStreamWriter(fout); |
@@ -363,7 +363,7 @@ public void testByteArrayToOutputStream() |
363 | 363 | throws Exception |
364 | 364 | { |
365 | 365 | File destination = newFile( "copy8.txt" ); |
366 | | - FileOutputStream fout = new FileOutputStream( destination ); |
| 366 | + OutputStream fout = Files.newOutputStream( destination.toPath() ); |
367 | 367 | FileInputStream fin = new FileInputStream( testFile ); |
368 | 368 |
|
369 | 369 | // Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid. |
|
0 commit comments