Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2018-02-25 23:58:48 +0000
committerDavid Pursehouse2018-02-25 23:58:48 +0000
commit4651d01e29aab1aac9c7c798695bafa8a04b25b1 (patch)
treef86d65452fbaaf9beb3152186b6a9eca872ccb3b /org.eclipse.jgit.test/tst
parentf0b46e1db47bfc11dc7f39b9cb4fc30a78ea7f16 (diff)
downloadjgit-4651d01e29aab1aac9c7c798695bafa8a04b25b1.tar.gz
jgit-4651d01e29aab1aac9c7c798695bafa8a04b25b1.tar.xz
jgit-4651d01e29aab1aac9c7c798695bafa8a04b25b1.zip
PullCommandTest: Use try-with-resources for File{Input,Output}Stream
Change-Id: I09242eb289655c7554aefa9e0817d9b881db656b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java15
1 files changed, 2 insertions, 13 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
index cc5a0249cb..3c3d1c83ec 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
@@ -591,24 +591,16 @@ public class PullCommandTest extends RepositoryTestCase {
private static void writeToFile(File actFile, String string)
throws IOException {
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(actFile);
+ try (FileOutputStream fos = new FileOutputStream(actFile)) {
fos.write(string.getBytes(UTF_8));
- fos.close();
- } finally {
- if (fos != null)
- fos.close();
}
}
private static void assertFileContentsEqual(File actFile, String string)
throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- FileInputStream fis = null;
byte[] buffer = new byte[100];
- try {
- fis = new FileInputStream(actFile);
+ try (FileInputStream fis = new FileInputStream(actFile)) {
int read = fis.read(buffer);
while (read > 0) {
bos.write(buffer, 0, read);
@@ -616,9 +608,6 @@ public class PullCommandTest extends RepositoryTestCase {
}
String content = new String(bos.toByteArray(), "UTF-8");
assertEquals(string, content);
- } finally {
- if (fis != null)
- fis.close();
}
}
}

Back to the top