You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/06/14 23:30:38 UTC
[commons-io] 02/03: PMD: Remove unnecessary final
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 1bd3a1f35ea95d4847aef44fac5cdb60f366c328
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 14 19:14:44 2022 -0400
PMD: Remove unnecessary final
---
src/main/java/org/apache/commons/io/FileUtils.java | 6 +-
src/main/java/org/apache/commons/io/IOUtils.java | 15 +++--
.../java/org/apache/commons/io/file/PathUtils.java | 8 +--
.../io/filefilter/MagicNumberFileFilter.java | 2 +-
.../commons/io/input/TimestampedObserver.java | 2 +-
.../commons/io/output/ByteArrayOutputStream.java | 2 +-
.../UnsynchronizedByteArrayOutputStream.java | 2 +-
.../apache/commons/io/FileCleaningTrackerTest.java | 2 +-
.../apache/commons/io/FileDeleteStrategyTest.java | 6 +-
.../io/FileUtilsCopyDirectoryToDirectoryTest.java | 4 +-
.../apache/commons/io/FileUtilsFileNewerTest.java | 4 +-
.../java/org/apache/commons/io/FileUtilsTest.java | 16 ++---
.../org/apache/commons/io/FilenameUtilsTest.java | 8 +--
.../org/apache/commons/io/IOUtilsCopyTest.java | 2 +-
.../java/org/apache/commons/io/IOUtilsTest.java | 6 +-
.../org/apache/commons/io/LineIteratorTest.java | 8 +--
.../io/comparator/CompositeFileComparatorTest.java | 8 +--
.../comparator/LastModifiedFileComparatorTest.java | 6 +-
.../io/comparator/SizeFileComparatorTest.java | 6 +-
.../commons/io/file/CopyDirectoryVisitorTest.java | 2 +-
.../commons/io/file/CountingPathVisitorTest.java | 2 +-
.../commons/io/file/DirectoryStreamFilterTest.java | 4 +-
.../commons/io/file/PathUtilsCountingTest.java | 2 +-
.../commons/io/file/PathUtilsIsEmptyTest.java | 4 +-
.../org/apache/commons/io/file/PathUtilsTest.java | 18 +++---
.../apache/commons/io/file/TempDirectoryTest.java | 4 +-
.../org/apache/commons/io/file/TempFileTest.java | 4 +-
.../commons/io/filefilter/FileFilterTest.java | 54 ++++++++--------
.../apache/commons/io/function/IOFunctionTest.java | 2 +-
.../commons/io/input/BOMInputStreamTest.java | 72 +++++++++++-----------
.../apache/commons/io/input/BoundedReaderTest.java | 26 ++++----
.../io/input/CharSequenceInputStreamTest.java | 2 +-
.../commons/io/input/CharSequenceReaderTest.java | 18 +++---
.../io/input/CharacterSetFilterReaderTest.java | 2 +-
.../io/input/ClassLoaderObjectInputStreamTest.java | 14 ++---
.../commons/io/input/ClosedInputStreamTest.java | 2 +-
.../apache/commons/io/input/ClosedReaderTest.java | 2 +-
.../commons/io/input/CountingInputStreamTest.java | 18 +++---
.../io/input/MarkShieldInputStreamTest.java | 16 ++---
.../MessageDigestCalculatingInputStreamTest.java | 2 +-
.../commons/io/input/NullInputStreamTest.java | 2 +-
.../apache/commons/io/input/NullReaderTest.java | 2 +-
.../io/input/ObservableInputStreamTest.java | 20 +++---
.../apache/commons/io/input/ProxyReaderTest.java | 4 +-
.../commons/io/input/QueueInputStreamTest.java | 8 +--
.../io/input/RandomAccessFileInputStreamTest.java | 18 +++---
.../commons/io/input/ReaderInputStreamTest.java | 8 +--
.../commons/io/input/SequenceReaderTest.java | 22 +++----
.../commons/io/input/StringInputStreamTest.java | 4 +-
.../apache/commons/io/input/TaggedReaderTest.java | 6 +-
.../org/apache/commons/io/input/TailerTest.java | 34 +++++-----
.../commons/io/input/TimestampedObserverTest.java | 4 +-
.../io/input/UncheckedBufferedReaderTest.java | 10 +--
.../io/input/UncheckedFilterInputStreamTest.java | 6 +-
.../io/input/UncheckedFilterReaderTest.java | 8 +--
.../io/input/WindowsLineEndingInputStreamTest.java | 2 +-
.../commons/io/input/XmlStreamReaderTest.java | 8 +--
.../buffer/CircularBufferInputStreamTest.java | 2 +-
.../XmlStreamReaderUtilitiesCompatibilityTest.java | 4 +-
.../io/output/ByteArrayOutputStreamTest.java | 40 ++++++------
.../commons/io/output/ChunkedOutputStreamTest.java | 4 +-
.../commons/io/output/ChunkedWriterTest.java | 8 +--
.../io/output/CountingOutputStreamTest.java | 2 +-
.../io/output/FileWriterWithEncodingTest.java | 18 +++---
.../commons/io/output/NullOutputStreamTest.java | 4 +-
.../commons/io/output/NullPrintStreamTest.java | 4 +-
.../apache/commons/io/output/NullWriterTest.java | 2 +-
.../io/output/ProxyCollectionWriterTest.java | 4 +-
.../apache/commons/io/output/ProxyWriterTest.java | 44 ++++++-------
.../commons/io/output/QueueOutputStreamTest.java | 6 +-
.../commons/io/output/StringBuilderWriterTest.java | 24 ++++----
.../commons/io/output/TaggedOutputStreamTest.java | 6 +-
.../apache/commons/io/output/TaggedWriterTest.java | 6 +-
.../commons/io/output/TeeOutputStreamTest.java | 2 +-
.../apache/commons/io/output/TeeWriterTest.java | 6 +-
.../io/output/ThresholdingOutputStreamTest.java | 12 ++--
.../commons/io/output/WriterOutputStreamTest.java | 12 ++--
.../commons/io/output/XmlStreamWriterTest.java | 2 +-
.../java/org/apache/commons/io/test/TestUtils.java | 8 +--
79 files changed, 384 insertions(+), 385 deletions(-)
diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 00ca23b8..e0829536 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -1068,7 +1068,7 @@ public class FileUtils {
* @throws IOException if an IO error occurs during copying
*/
public static void copyURLToFile(final URL source, final File destination) throws IOException {
- try (final InputStream stream = source.openStream()) {
+ try (InputStream stream = source.openStream()) {
final Path path = destination.toPath();
PathUtils.createParentDirectories(path);
Files.copy(stream, path, StandardCopyOption.REPLACE_EXISTING);
@@ -1096,10 +1096,10 @@ public class FileUtils {
*/
public static void copyURLToFile(final URL source, final File destination, final int connectionTimeoutMillis, final int readTimeoutMillis)
throws IOException {
- try (final CloseableURLConnection urlConnection = CloseableURLConnection.open(source)) {
+ try (CloseableURLConnection urlConnection = CloseableURLConnection.open(source)) {
urlConnection.setConnectTimeout(connectionTimeoutMillis);
urlConnection.setReadTimeout(readTimeoutMillis);
- try (final InputStream stream = urlConnection.getInputStream()) {
+ try (InputStream stream = urlConnection.getInputStream()) {
copyInputStreamToFile(stream, destination);
}
}
diff --git a/src/main/java/org/apache/commons/io/IOUtils.java b/src/main/java/org/apache/commons/io/IOUtils.java
index 23611852..4eed654a 100644
--- a/src/main/java/org/apache/commons/io/IOUtils.java
+++ b/src/main/java/org/apache/commons/io/IOUtils.java
@@ -2485,10 +2485,9 @@ public class IOUtils {
*/
public static byte[] toByteArray(final InputStream inputStream) throws IOException {
// We use a ThresholdingOutputStream to avoid reading AND writing more than Integer.MAX_VALUE.
- try (final UnsynchronizedByteArrayOutputStream ubaOutput = new UnsynchronizedByteArrayOutputStream();
- final ThresholdingOutputStream thresholdOuput = new ThresholdingOutputStream(Integer.MAX_VALUE, os -> {
- throw new IllegalArgumentException(
- String.format("Cannot read more than %,d into a byte array", Integer.MAX_VALUE));
+ try (UnsynchronizedByteArrayOutputStream ubaOutput = new UnsynchronizedByteArrayOutputStream();
+ ThresholdingOutputStream thresholdOuput = new ThresholdingOutputStream(Integer.MAX_VALUE, os -> {
+ throw new IllegalArgumentException(String.format("Cannot read more than %,d into a byte array", Integer.MAX_VALUE));
}, os -> ubaOutput)) {
copy(inputStream, thresholdOuput);
return ubaOutput.toByteArray();
@@ -2589,7 +2588,7 @@ public class IOUtils {
* @since 2.3
*/
public static byte[] toByteArray(final Reader reader, final Charset charset) throws IOException {
- try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) {
+ try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
copy(reader, output, charset);
return output.toByteArray();
}
@@ -2662,7 +2661,7 @@ public class IOUtils {
* @since 2.4
*/
public static byte[] toByteArray(final URL url) throws IOException {
- try (final CloseableURLConnection urlConnection = CloseableURLConnection.open(url)) {
+ try (CloseableURLConnection urlConnection = CloseableURLConnection.open(url)) {
return IOUtils.toByteArray(urlConnection);
}
}
@@ -2930,7 +2929,7 @@ public class IOUtils {
* @since 2.3
*/
public static String toString(final InputStream input, final Charset charset) throws IOException {
- try (final StringBuilderWriter sw = new StringBuilderWriter()) {
+ try (StringBuilderWriter sw = new StringBuilderWriter()) {
copy(input, sw, charset);
return sw.toString();
}
@@ -2975,7 +2974,7 @@ public class IOUtils {
* @throws IOException if an I/O error occurs
*/
public static String toString(final Reader reader) throws IOException {
- try (final StringBuilderWriter sw = new StringBuilderWriter()) {
+ try (StringBuilderWriter sw = new StringBuilderWriter()) {
copy(reader, sw);
return sw.toString();
}
diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java b/src/main/java/org/apache/commons/io/file/PathUtils.java
index d5041bce..be9aae47 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -277,7 +277,7 @@ public final class PathUtils {
* @see Files#copy(InputStream, Path, CopyOption...)
*/
public static Path copyFile(final URL sourceFile, final Path targetFile, final CopyOption... copyOptions) throws IOException {
- try (final InputStream inputStream = sourceFile.openStream()) {
+ try (InputStream inputStream = sourceFile.openStream()) {
Files.copy(inputStream, targetFile, copyOptions);
return targetFile;
}
@@ -308,7 +308,7 @@ public final class PathUtils {
* @see Files#copy(InputStream, Path, CopyOption...)
*/
public static Path copyFileToDirectory(final URL sourceFile, final Path targetDirectory, final CopyOption... copyOptions) throws IOException {
- try (final InputStream inputStream = sourceFile.openStream()) {
+ try (InputStream inputStream = sourceFile.openStream()) {
Files.copy(inputStream, targetDirectory.resolve(sourceFile.getFile()), copyOptions);
return targetDirectory;
}
@@ -721,8 +721,8 @@ public final class PathUtils {
// same file
return true;
}
- try (final InputStream inputStream1 = Files.newInputStream(nPath1, openOptions);
- final InputStream inputStream2 = Files.newInputStream(nPath2, openOptions)) {
+ try (InputStream inputStream1 = Files.newInputStream(nPath1, openOptions);
+ InputStream inputStream2 = Files.newInputStream(nPath2, openOptions)) {
return IOUtils.contentEquals(inputStream1, inputStream2);
}
}
diff --git a/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java b/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
index 49277729..9e705856 100644
--- a/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
+++ b/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java
@@ -292,7 +292,7 @@ public class MagicNumberFileFilter extends AbstractFileFilter implements
public FileVisitResult accept(final Path file, final BasicFileAttributes attributes) {
if (file != null && Files.isRegularFile(file) && Files.isReadable(file)) {
try {
- try (final FileChannel fileChannel = FileChannel.open(file)) {
+ try (FileChannel fileChannel = FileChannel.open(file)) {
final ByteBuffer byteBuffer = ByteBuffer.allocate(this.magicNumbers.length);
final int read = fileChannel.read(byteBuffer);
if (read != magicNumbers.length) {
diff --git a/src/main/java/org/apache/commons/io/input/TimestampedObserver.java b/src/main/java/org/apache/commons/io/input/TimestampedObserver.java
index ef8fc881..e577fa4e 100644
--- a/src/main/java/org/apache/commons/io/input/TimestampedObserver.java
+++ b/src/main/java/org/apache/commons/io/input/TimestampedObserver.java
@@ -31,7 +31,7 @@ import org.apache.commons.io.input.ObservableInputStream.Observer;
*
* <pre>
* final TimestampedObserver timetampedObserver = new TimestampedObserver();
- * try (final ObservableInputStream inputStream = new ObservableInputStream(...),
+ * try (ObservableInputStream inputStream = new ObservableInputStream(...),
* timetampedObserver)) {
* ...
* }
diff --git a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
index 025952e2..78662eb9 100644
--- a/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
@@ -78,7 +78,7 @@ public class ByteArrayOutputStream extends AbstractByteArrayOutputStream {
*/
public static InputStream toBufferedInputStream(final InputStream input, final int size)
throws IOException {
- try (final ByteArrayOutputStream output = new ByteArrayOutputStream(size)) {
+ try (ByteArrayOutputStream output = new ByteArrayOutputStream(size)) {
output.write(input);
return output.toInputStream();
}
diff --git a/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java b/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java
index 8d77f2f8..6421f68f 100644
--- a/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java
+++ b/src/main/java/org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream.java
@@ -71,7 +71,7 @@ public final class UnsynchronizedByteArrayOutputStream extends AbstractByteArray
*/
public static InputStream toBufferedInputStream(final InputStream input, final int size) throws IOException {
// It does not matter if a ByteArrayOutputStream is not closed as close() is a no-op
- try (final UnsynchronizedByteArrayOutputStream output = new UnsynchronizedByteArrayOutputStream(size)) {
+ try (UnsynchronizedByteArrayOutputStream output = new UnsynchronizedByteArrayOutputStream(size)) {
output.write(input);
return output.toInputStream();
}
diff --git a/src/test/java/org/apache/commons/io/FileCleaningTrackerTest.java b/src/test/java/org/apache/commons/io/FileCleaningTrackerTest.java
index af8c28cd..a6e4e5aa 100644
--- a/src/test/java/org/apache/commons/io/FileCleaningTrackerTest.java
+++ b/src/test/java/org/apache/commons/io/FileCleaningTrackerTest.java
@@ -127,7 +127,7 @@ public class FileCleaningTrackerTest extends AbstractTempDirTest {
throw new IOException("Cannot create file " + testFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(testFile.toPath()))) {
TestUtils.generateTestData(output, 100);
}
diff --git a/src/test/java/org/apache/commons/io/FileDeleteStrategyTest.java b/src/test/java/org/apache/commons/io/FileDeleteStrategyTest.java
index db4dd9ce..4a78c169 100644
--- a/src/test/java/org/apache/commons/io/FileDeleteStrategyTest.java
+++ b/src/test/java/org/apache/commons/io/FileDeleteStrategyTest.java
@@ -49,7 +49,7 @@ public class FileDeleteStrategyTest {
throw new IOException("Cannot create file " + subFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(subFile.toPath()))) {
TestUtils.generateTestData(output, 16);
}
@@ -75,7 +75,7 @@ public class FileDeleteStrategyTest {
throw new IOException("Cannot create file " + subFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(subFile.toPath()))) {
TestUtils.generateTestData(output, 16);
}
@@ -114,7 +114,7 @@ public class FileDeleteStrategyTest {
throw new IOException("Cannot create file " + subFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(subFile.toPath()))) {
TestUtils.generateTestData(output, 16);
}
diff --git a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTest.java b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTest.java
index 3334b268..5102f261 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTest.java
@@ -74,7 +74,7 @@ public class FileUtilsCopyDirectoryToDirectoryTest {
@Test
public void copyDirectoryToDirectoryThrowsIllegalExceptionWithCorrectMessageWhenSrcDirIsNotDirectory()
throws IOException {
- try (final TempFile srcDir = TempFile.create("notadireotry", null)) {
+ try (TempFile srcDir = TempFile.create("notadireotry", null)) {
final File destDir = new File(temporaryFolder, "destinationDirectory");
destDir.mkdirs();
final String expectedMessage = String.format("Parameter 'sourceDir' is not a directory: '%s'", srcDir);
@@ -100,7 +100,7 @@ public class FileUtilsCopyDirectoryToDirectoryTest {
@Test
public void copyFileAndCheckAcl() throws IOException {
- try (final TempFile sourcePath = TempFile.create("TempOutput", ".bin")) {
+ try (TempFile sourcePath = TempFile.create("TempOutput", ".bin")) {
final Path destPath = Paths.get(temporaryFolder.getAbsolutePath(), "SomeFile.bin");
// Test copy attributes without replace FIRST.
FileUtils.copyFile(sourcePath.toFile(), destPath.toFile(), true, StandardCopyOption.COPY_ATTRIBUTES);
diff --git a/src/test/java/org/apache/commons/io/FileUtilsFileNewerTest.java b/src/test/java/org/apache/commons/io/FileUtilsFileNewerTest.java
index a7b1da8d..51eef36d 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsFileNewerTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsFileNewerTest.java
@@ -54,13 +54,13 @@ public class FileUtilsFileNewerTest {
if (!testFile1.getParentFile().exists()) {
throw new IOException("Cannot create file " + testFile1 + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
TestUtils.generateTestData(output1, FILE1_SIZE);
}
if (!testFile2.getParentFile().exists()) {
throw new IOException("Cannot create file " + testFile2 + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
TestUtils.generateTestData(output, FILE2_SIZE);
}
}
diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java
index 1d431c14..109bdc95 100644
--- a/src/test/java/org/apache/commons/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -318,7 +318,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
throw new IOException("Cannot create file " + testFile1
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output3 =
+ try (BufferedOutputStream output3 =
new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
TestUtils.generateTestData(output3, testFile1Size);
}
@@ -326,7 +326,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
throw new IOException("Cannot create file " + testFile2
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 =
+ try (BufferedOutputStream output2 =
new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
TestUtils.generateTestData(output2, testFile2Size);
}
@@ -336,7 +336,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
throw new IOException("Cannot create file " + testFile1
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 =
+ try (BufferedOutputStream output1 =
new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
TestUtils.generateTestData(output1, testFile1Size);
}
@@ -344,7 +344,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
throw new IOException("Cannot create file " + testFile2
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
TestUtils.generateTestData(output, testFile2Size);
}
@@ -1628,7 +1628,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
assertFalse(FileUtils.isDirectory(testFile1));
final File tempDirAsFile;
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
tempDirAsFile = tempDir.toFile();
assertTrue(FileUtils.isDirectory(tempDirAsFile));
}
@@ -1637,7 +1637,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
@Test
public void testIsEmptyDirectory() throws IOException {
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
final File tempDirAsFile = tempDir.toFile();
Assertions.assertTrue(FileUtils.isEmptyDirectory(tempDirAsFile));
}
@@ -1884,7 +1884,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
final WildcardFileFilter fileFilterAllDirs = new WildcardFileFilter("*");
final WildcardFileFilter fileFilterExtTxt = new WildcardFileFilter("*.txt");
try {
- try (final OutputStream output = new BufferedOutputStream(Files.newOutputStream(someFile.toPath()))) {
+ try (OutputStream output = new BufferedOutputStream(Files.newOutputStream(someFile.toPath()))) {
TestUtils.generateTestData(output, 100);
}
//
@@ -2700,7 +2700,7 @@ public class FileUtilsTest extends AbstractTempDirTest {
assertFalse(file.exists(), "Bad test: test file still exists");
FileUtils.touch(file);
assertTrue(file.exists(), "FileUtils.touch() created file");
- try (final OutputStream out = Files.newOutputStream(file.toPath())) {
+ try (OutputStream out = Files.newOutputStream(file.toPath())) {
assertEquals(0, file.length(), "Created empty file.");
out.write(0);
}
diff --git a/src/test/java/org/apache/commons/io/FilenameUtilsTest.java b/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
index 166a78b2..aa1ea8a1 100644
--- a/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/FilenameUtilsTest.java
@@ -65,7 +65,7 @@ public class FilenameUtilsTest {
throw new IOException("Cannot create file " + testFile1
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output3 =
+ try (BufferedOutputStream output3 =
new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
TestUtils.generateTestData(output3, testFile1Size);
}
@@ -73,7 +73,7 @@ public class FilenameUtilsTest {
throw new IOException("Cannot create file " + testFile2
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 =
+ try (BufferedOutputStream output2 =
new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
TestUtils.generateTestData(output2, testFile2Size);
}
@@ -81,7 +81,7 @@ public class FilenameUtilsTest {
throw new IOException("Cannot create file " + testFile1
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 =
+ try (BufferedOutputStream output1 =
new BufferedOutputStream(Files.newOutputStream(testFile1.toPath()))) {
TestUtils.generateTestData(output1, testFile1Size);
}
@@ -89,7 +89,7 @@ public class FilenameUtilsTest {
throw new IOException("Cannot create file " + testFile2
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(testFile2.toPath()))) {
TestUtils.generateTestData(output, testFile2Size);
}
diff --git a/src/test/java/org/apache/commons/io/IOUtilsCopyTest.java b/src/test/java/org/apache/commons/io/IOUtilsCopyTest.java
index ee39b3ab..6a81fdae 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsCopyTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsCopyTest.java
@@ -462,7 +462,7 @@ public class IOUtilsCopyTest {
final URL in = getClass().getResource(name);
assertNotNull(in, name);
- try (final TempFile path = TempFile.create("testCopy_URLToFile", ".txt")) {
+ try (TempFile path = TempFile.create("testCopy_URLToFile", ".txt")) {
IOUtils.copy(in, path.toFile());
assertArrayEquals(Files.readAllBytes(Paths.get("src/test/resources" + name)), Files.readAllBytes(path.get()));
}
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTest.java b/src/test/java/org/apache/commons/io/IOUtilsTest.java
index 114b5be8..ab140520 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTest.java
@@ -270,7 +270,7 @@ public class IOUtilsTest {
@Test
public void testAsWriterAppendable() throws IOException {
final Appendable a = new StringBuffer();
- try (final Writer w = IOUtils.writer(a)) {
+ try (Writer w = IOUtils.writer(a)) {
assertNotSame(w, a);
assertEquals(AppendableWriter.class, w.getClass());
assertSame(w, IOUtils.writer(w));
@@ -285,7 +285,7 @@ public class IOUtilsTest {
@Test
public void testAsWriterStringBuilder() throws IOException {
final Appendable a = new StringBuilder();
- try (final Writer w = IOUtils.writer(a)) {
+ try (Writer w = IOUtils.writer(a)) {
assertNotSame(w, a);
assertEquals(StringBuilderWriter.class, w.getClass());
assertSame(w, IOUtils.writer(w));
@@ -1481,7 +1481,7 @@ public class IOUtilsTest {
@Test
public void testToByteArray_URLConnection() throws Exception {
final byte[] actual;
- try (final CloseableURLConnection urlConnection = CloseableURLConnection.open(testFile.toURI())) {
+ try (CloseableURLConnection urlConnection = CloseableURLConnection.open(testFile.toURI())) {
actual = IOUtils.toByteArray(urlConnection);
}
assertEquals(FILE_SIZE, actual.length);
diff --git a/src/test/java/org/apache/commons/io/LineIteratorTest.java b/src/test/java/org/apache/commons/io/LineIteratorTest.java
index d12dc212..e6cb8fde 100644
--- a/src/test/java/org/apache/commons/io/LineIteratorTest.java
+++ b/src/test/java/org/apache/commons/io/LineIteratorTest.java
@@ -122,7 +122,7 @@ public class LineIteratorTest {
final File testFile = new File(temporaryFolder, fileName);
final List<String> lines = createLinesFile(testFile, encoding, lineCount);
- try (final LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
+ try (LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
assertThrows(UnsupportedOperationException.class, iterator::remove);
int idx = 0;
@@ -147,7 +147,7 @@ public class LineIteratorTest {
final File testFile = new File(temporaryFolder, "LineIterator-closeEarly.txt");
createLinesFile(testFile, encoding, 3);
- try (final LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
+ try (LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
// get
assertNotNull("Line expected", iterator.next());
assertTrue(iterator.hasNext(), "More expected");
@@ -290,7 +290,7 @@ public class LineIteratorTest {
final File testFile = new File(temporaryFolder, "LineIterator-nextOnly.txt");
final List<String> lines = createLinesFile(testFile, encoding, 3);
- try (final LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
+ try (LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
for (int i = 0; i < lines.size(); i++) {
final String line = iterator.next();
assertEquals(lines.get(i), line, "next() line " + i);
@@ -334,7 +334,7 @@ public class LineIteratorTest {
final File testFile = new File(temporaryFolder, "LineIterator-validEncoding.txt");
createLinesFile(testFile, encoding, 3);
- try (final LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
+ try (LineIterator iterator = FileUtils.lineIterator(testFile, encoding)) {
int count = 0;
while (iterator.hasNext()) {
assertNotNull(iterator.next());
diff --git a/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java b/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
index 90c31d9f..8585ec48 100644
--- a/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
+++ b/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java
@@ -86,7 +86,7 @@ public class CompositeFileComparatorTest extends ComparatorAbstractTest {
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output3 =
+ try (BufferedOutputStream output3 =
new BufferedOutputStream(Files.newOutputStream(lessFile.toPath()))) {
TestUtils.generateTestData(output3, 32);
}
@@ -94,7 +94,7 @@ public class CompositeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + equalFile1
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 =
+ try (BufferedOutputStream output2 =
new BufferedOutputStream(Files.newOutputStream(equalFile1.toPath()))) {
TestUtils.generateTestData(output2, 48);
}
@@ -102,7 +102,7 @@ public class CompositeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + equalFile2
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 =
+ try (BufferedOutputStream output1 =
new BufferedOutputStream(Files.newOutputStream(equalFile2.toPath()))) {
TestUtils.generateTestData(output1, 48);
}
@@ -110,7 +110,7 @@ public class CompositeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + moreFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(moreFile.toPath()))) {
TestUtils.generateTestData(output, 48);
}
diff --git a/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java b/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java
index 3cda9b25..5ce2e5da 100644
--- a/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java
+++ b/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java
@@ -38,7 +38,7 @@ public class LastModifiedFileComparatorTest extends ComparatorAbstractTest {
if (!olderFile.getParentFile().exists()) {
throw new IOException("Cannot create file " + olderFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(olderFile.toPath()))) {
+ try (BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(olderFile.toPath()))) {
TestUtils.generateTestData(output2, 0);
}
@@ -46,7 +46,7 @@ public class LastModifiedFileComparatorTest extends ComparatorAbstractTest {
if (!equalFile.getParentFile().exists()) {
throw new IOException("Cannot create file " + equalFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(equalFile.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(equalFile.toPath()))) {
TestUtils.generateTestData(output1, 0);
}
do {
@@ -58,7 +58,7 @@ public class LastModifiedFileComparatorTest extends ComparatorAbstractTest {
if (!newerFile.getParentFile().exists()) {
throw new IOException("Cannot create file " + newerFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(newerFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(newerFile.toPath()))) {
TestUtils.generateTestData(output, 0);
}
do {
diff --git a/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java b/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java
index c8c0dc32..58ca05d1 100644
--- a/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java
+++ b/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java
@@ -55,7 +55,7 @@ public class SizeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + smallerFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 =
+ try (BufferedOutputStream output2 =
new BufferedOutputStream(Files.newOutputStream(smallerFile.toPath()))) {
TestUtils.generateTestData(output2, 32);
}
@@ -63,7 +63,7 @@ public class SizeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + equalFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 =
+ try (BufferedOutputStream output1 =
new BufferedOutputStream(Files.newOutputStream(equalFile.toPath()))) {
TestUtils.generateTestData(output1, 48);
}
@@ -71,7 +71,7 @@ public class SizeFileComparatorTest extends ComparatorAbstractTest {
throw new IOException("Cannot create file " + largerFile
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(largerFile.toPath()))) {
TestUtils.generateTestData(output, 64);
}
diff --git a/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java b/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
index 10dc7203..ffdd40bc 100644
--- a/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
+++ b/src/test/java/org/apache/commons/io/file/CopyDirectoryVisitorTest.java
@@ -43,7 +43,7 @@ public class CopyDirectoryVisitorTest extends TestArguments {
@ParameterizedTest
@MethodSource("pathCounters")
public void testCopyDirectoryEmptyFolder(final PathCounters pathCounters) throws IOException {
- try (final TempDirectory sourceDir = TempDirectory.create(getClass().getSimpleName())) {
+ try (TempDirectory sourceDir = TempDirectory.create(getClass().getSimpleName())) {
assertCounts(1, 0, 0, PathUtils
.visitFileTree(new CopyDirectoryVisitor(pathCounters, sourceDir, targetDir, StandardCopyOption.REPLACE_EXISTING), sourceDir.get()));
}
diff --git a/src/test/java/org/apache/commons/io/file/CountingPathVisitorTest.java b/src/test/java/org/apache/commons/io/file/CountingPathVisitorTest.java
index b3529b19..973bb0b3 100644
--- a/src/test/java/org/apache/commons/io/file/CountingPathVisitorTest.java
+++ b/src/test/java/org/apache/commons/io/file/CountingPathVisitorTest.java
@@ -42,7 +42,7 @@ public class CountingPathVisitorTest extends TestArguments {
@MethodSource("countingPathVisitors")
public void testCountEmptyFolder(final CountingPathVisitor visitor) throws IOException {
checkZeroCounts(visitor);
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
assertCounts(1, 0, 0, PathUtils.visitFileTree(visitor, tempDir.get()));
}
}
diff --git a/src/test/java/org/apache/commons/io/file/DirectoryStreamFilterTest.java b/src/test/java/org/apache/commons/io/file/DirectoryStreamFilterTest.java
index 70cb1a53..6d5bb3e9 100644
--- a/src/test/java/org/apache/commons/io/file/DirectoryStreamFilterTest.java
+++ b/src/test/java/org/apache/commons/io/file/DirectoryStreamFilterTest.java
@@ -41,7 +41,7 @@ public class DirectoryStreamFilterTest {
final PathFilter pathFilter = new NameFileFilter(PATH_FIXTURE);
final DirectoryStreamFilter streamFilter = new DirectoryStreamFilter(pathFilter);
assertEquals(pathFilter, streamFilter.getPathFilter());
- try (final DirectoryStream<Path> stream = Files.newDirectoryStream(PathUtils.current(), streamFilter)) {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(PathUtils.current(), streamFilter)) {
final Iterator<Path> iterator = stream.iterator();
final Path path = iterator.next();
assertEquals(PATH_FIXTURE, path.getFileName().toString());
@@ -54,7 +54,7 @@ public class DirectoryStreamFilterTest {
final PathFilter pathFilter = new NameFileFilter(PATH_FIXTURE).negate();
final DirectoryStreamFilter streamFilter = new DirectoryStreamFilter(pathFilter);
assertEquals(pathFilter, streamFilter.getPathFilter());
- try (final DirectoryStream<Path> stream = Files.newDirectoryStream(PathUtils.current(), streamFilter)) {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(PathUtils.current(), streamFilter)) {
for (final Path path : stream) {
assertNotEquals(PATH_FIXTURE, path.getFileName().toString());
}
diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsCountingTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsCountingTest.java
index 62cff92f..0092bd00 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsCountingTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsCountingTest.java
@@ -35,7 +35,7 @@ public class PathUtilsCountingTest {
*/
@Test
public void testCountEmptyFolder() throws IOException {
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
final PathCounters pathCounts = PathUtils.countDirectory(tempDir.get());
assertCounts(1, 0, 0, pathCounts);
}
diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsIsEmptyTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsIsEmptyTest.java
index 709afaed..e5be7308 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsIsEmptyTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsIsEmptyTest.java
@@ -41,7 +41,7 @@ public class PathUtilsIsEmptyTest {
public void testIsEmpty() throws IOException {
Assertions.assertTrue(PathUtils.isEmpty(FILE_SIZE_0));
Assertions.assertFalse(PathUtils.isEmpty(FILE_SIZE_1));
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
Assertions.assertTrue(PathUtils.isEmpty(tempDir.get()));
}
Assertions.assertFalse(PathUtils.isEmpty(DIR_SIZE_1));
@@ -49,7 +49,7 @@ public class PathUtilsIsEmptyTest {
@Test
public void testIsEmptyDirectory() throws IOException {
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
Assertions.assertTrue(PathUtils.isEmptyDirectory(tempDir.get()));
}
Assertions.assertFalse(PathUtils.isEmptyDirectory(DIR_SIZE_1));
diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
index bc76f7fd..503828fb 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsTest.java
@@ -111,7 +111,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
@Test
public void testCopyDirectoryForDifferentFilesystemsWithAbsolutePath() throws IOException {
final Path archivePath = Paths.get(TEST_JAR_PATH);
- try (final FileSystem archive = openArchive(archivePath, false)) {
+ try (FileSystem archive = openArchive(archivePath, false)) {
// relative jar -> absolute dir
Path sourceDir = archive.getPath("dir1");
PathUtils.copyDirectory(sourceDir, tempDirPath);
@@ -126,7 +126,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
@Test
public void testCopyDirectoryForDifferentFilesystemsWithAbsolutePathReverse() throws IOException {
- try (final FileSystem archive = openArchive(tempDirPath.resolve(TEST_JAR_NAME), true)) {
+ try (FileSystem archive = openArchive(tempDirPath.resolve(TEST_JAR_NAME), true)) {
// absolute dir -> relative jar
Path targetDir = archive.getPath("target");
Files.createDirectory(targetDir);
@@ -144,7 +144,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
@Test
public void testCopyDirectoryForDifferentFilesystemsWithRelativePath() throws IOException {
final Path archivePath = Paths.get(TEST_JAR_PATH);
- try (final FileSystem archive = openArchive(archivePath, false);
+ try (FileSystem archive = openArchive(archivePath, false);
final FileSystem targetArchive = openArchive(tempDirPath.resolve(TEST_JAR_NAME), true)) {
final Path targetDir = targetArchive.getPath("targetDir");
Files.createDirectory(targetDir);
@@ -162,7 +162,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
@Test
public void testCopyDirectoryForDifferentFilesystemsWithRelativePathReverse() throws IOException {
- try (final FileSystem archive = openArchive(tempDirPath.resolve(TEST_JAR_NAME), true)) {
+ try (FileSystem archive = openArchive(tempDirPath.resolve(TEST_JAR_NAME), true)) {
// relative dir -> relative jar
Path targetDir = archive.getPath("target");
Files.createDirectory(targetDir);
@@ -238,11 +238,11 @@ public class PathUtilsTest extends AbstractTempDirTest {
assertFalse(PathUtils.isDirectory(null));
assertTrue(PathUtils.isDirectory(tempDirPath));
- try (final TempFile testFile1 = TempFile.create(tempDirPath, "prefix", null)) {
+ try (TempFile testFile1 = TempFile.create(tempDirPath, "prefix", null)) {
assertFalse(PathUtils.isDirectory(testFile1.get()));
Path ref = null;
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
ref = tempDir.get();
assertTrue(PathUtils.isDirectory(tempDir.get()));
}
@@ -267,7 +267,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
assertFalse(PathUtils.isRegularFile(null));
assertFalse(PathUtils.isRegularFile(tempDirPath));
- try (final TempFile testFile1 = TempFile.create(tempDirPath, "prefix", null)) {
+ try (TempFile testFile1 = TempFile.create(tempDirPath, "prefix", null)) {
assertTrue(PathUtils.isRegularFile(testFile1.get()));
Files.delete(testFile1.get());
@@ -278,7 +278,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
@Test
public void testNewDirectoryStream() throws Exception {
final PathFilter pathFilter = new NameFileFilter(PATH_FIXTURE);
- try (final DirectoryStream<Path> stream = PathUtils.newDirectoryStream(PathUtils.current(), pathFilter)) {
+ try (DirectoryStream<Path> stream = PathUtils.newDirectoryStream(PathUtils.current(), pathFilter)) {
final Iterator<Path> iterator = stream.iterator();
final Path path = iterator.next();
assertEquals(PATH_FIXTURE, path.getFileName().toString());
@@ -429,7 +429,7 @@ public class PathUtilsTest extends AbstractTempDirTest {
assertFalse(Files.exists(file), "Bad test: test file still exists");
PathUtils.touch(file);
assertTrue(Files.exists(file), "touch() created file");
- try (final OutputStream out = Files.newOutputStream(file)) {
+ try (OutputStream out = Files.newOutputStream(file)) {
assertEquals(0, Files.size(file), "Created empty file.");
out.write(0);
}
diff --git a/src/test/java/org/apache/commons/io/file/TempDirectoryTest.java b/src/test/java/org/apache/commons/io/file/TempDirectoryTest.java
index 4cc7f02d..05e5a916 100644
--- a/src/test/java/org/apache/commons/io/file/TempDirectoryTest.java
+++ b/src/test/java/org/apache/commons/io/file/TempDirectoryTest.java
@@ -36,7 +36,7 @@ public class TempDirectoryTest {
@Test
public void testCreatePath() throws IOException {
final TempDirectory ref;
- try (final TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(getClass().getCanonicalName())) {
ref = tempDir;
assertTrue(FileUtils.isEmptyDirectory(tempDir.toFile()));
}
@@ -51,7 +51,7 @@ public class TempDirectoryTest {
@Test
public void testCreateString() throws IOException {
final TempDirectory ref;
- try (final TempDirectory tempDir = TempDirectory.create(Paths.get("target"), getClass().getCanonicalName())) {
+ try (TempDirectory tempDir = TempDirectory.create(Paths.get("target"), getClass().getCanonicalName())) {
ref = tempDir;
assertTrue(FileUtils.isEmptyDirectory(tempDir.toFile()));
}
diff --git a/src/test/java/org/apache/commons/io/file/TempFileTest.java b/src/test/java/org/apache/commons/io/file/TempFileTest.java
index 55bfbe09..566926af 100644
--- a/src/test/java/org/apache/commons/io/file/TempFileTest.java
+++ b/src/test/java/org/apache/commons/io/file/TempFileTest.java
@@ -35,7 +35,7 @@ public class TempFileTest {
@Test
public void testCreatePath() throws IOException {
final TempFile ref;
- try (final TempFile tempDir = TempFile.create(Paths.get("target"), "prefix", ".suffix")) {
+ try (TempFile tempDir = TempFile.create(Paths.get("target"), "prefix", ".suffix")) {
ref = tempDir;
assertTrue(Files.exists(ref.get()));
}
@@ -50,7 +50,7 @@ public class TempFileTest {
@Test
public void testCreateString() throws IOException {
final TempFile ref;
- try (final TempFile tempDir = TempFile.create(getClass().getCanonicalName(), ".suffix")) {
+ try (TempFile tempDir = TempFile.create(getClass().getCanonicalName(), ".suffix")) {
ref = tempDir;
assertTrue(Files.exists(ref.get()));
}
diff --git a/src/test/java/org/apache/commons/io/filefilter/FileFilterTest.java b/src/test/java/org/apache/commons/io/filefilter/FileFilterTest.java
index 7556c7db..b82f98f7 100644
--- a/src/test/java/org/apache/commons/io/filefilter/FileFilterTest.java
+++ b/src/test/java/org/apache/commons/io/filefilter/FileFilterTest.java
@@ -68,7 +68,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!oldFile.getParentFile().exists()) {
fail("Cannot create file " + oldFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(oldFile.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(oldFile.toPath()))) {
TestUtils.generateTestData(output1, 0);
}
@@ -81,7 +81,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!reference.getParentFile().exists()) {
fail("Cannot create file " + reference + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(reference.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(reference.toPath()))) {
TestUtils.generateTestData(output, 0);
}
} while (equalsLastModified(oldFile, reference));
@@ -98,7 +98,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!newFile.getParentFile().exists()) {
fail("Cannot create file " + newFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(newFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(newFile.toPath()))) {
TestUtils.generateTestData(output, 0);
}
} while (equalsLastModified(reference, newFile));
@@ -197,9 +197,9 @@ public class FileFilterTest extends AbstractFilterTest {
@Test
public void testCanExecute() throws Exception {
assumeTrue(SystemUtils.IS_OS_WINDOWS);
- try (final TempFile executablePath = TempFile.create(getClass().getSimpleName(), null)) {
+ try (TempFile executablePath = TempFile.create(getClass().getSimpleName(), null)) {
final File executableFile = executablePath.toFile();
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(executablePath.get()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(executablePath.get()))) {
TestUtils.generateTestData(output, 32);
}
assertTrue(executableFile.setExecutable(true));
@@ -218,7 +218,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!readOnlyFile.getParentFile().exists()) {
fail("Cannot create file " + readOnlyFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(readOnlyFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(readOnlyFile.toPath()))) {
TestUtils.generateTestData(output, 32);
}
assertTrue(readOnlyFile.setReadOnly());
@@ -238,7 +238,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!readOnlyFile.getParentFile().exists()) {
fail("Cannot create file " + readOnlyFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(readOnlyFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(readOnlyFile.toPath()))) {
TestUtils.generateTestData(output, 32);
}
assertTrue(readOnlyFile.setReadOnly());
@@ -391,7 +391,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!emptyFile.getParentFile().exists()) {
fail("Cannot create file " + emptyFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(emptyFile.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(emptyFile.toPath()))) {
TestUtils.generateTestData(output1, 0);
}
assertFiltering(EmptyFileFilter.EMPTY, emptyFile, true);
@@ -411,7 +411,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!notEmptyFile.getParentFile().exists()) {
fail("Cannot create file " + notEmptyFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(notEmptyFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(notEmptyFile.toPath()))) {
TestUtils.generateTestData(output, 32);
}
assertFiltering(EmptyFileFilter.EMPTY, notEmptyFile, false);
@@ -726,7 +726,7 @@ public class FileFilterTest extends AbstractFilterTest {
final Path dirPath = dirFile.toPath();
dirFile.mkdirs();
- try (final OutputStream classFileAStream = FileUtils.openOutputStream(classAFile)) {
+ try (OutputStream classFileAStream = FileUtils.openOutputStream(classAFile)) {
IOUtils.write(classFileMagicNumber, classFileAStream);
TestUtils.generateTestData(classFileAStream, 32);
}
@@ -767,7 +767,7 @@ public class FileFilterTest extends AbstractFilterTest {
final File dir = new File(temporaryFolder, "D");
dir.mkdirs();
- try (final OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA)) {
+ try (OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA)) {
TestUtils.generateTestData(tarFileAStream, tarMagicNumberOffset);
IOUtils.write(tarMagicNumber, tarFileAStream);
}
@@ -775,7 +775,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!randomFileB.getParentFile().exists()) {
fail("Cannot create file " + randomFileB + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(randomFileB.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(randomFileB.toPath()))) {
TestUtils.generateTestData(output, 2 * tarMagicNumberOffset);
}
@@ -805,7 +805,7 @@ public class FileFilterTest extends AbstractFilterTest {
final File dir = new File(temporaryFolder, "D");
dir.mkdirs();
- try (final OutputStream classFileAStream = FileUtils.openOutputStream(classFileA)) {
+ try (OutputStream classFileAStream = FileUtils.openOutputStream(classFileA)) {
IOUtils.write(classFileMagicNumber, classFileAStream);
TestUtils.generateTestData(classFileAStream, 32);
}
@@ -835,7 +835,7 @@ public class FileFilterTest extends AbstractFilterTest {
final File dir = new File(temporaryFolder, "D");
dir.mkdirs();
- try (final OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA)) {
+ try (OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA)) {
TestUtils.generateTestData(tarFileAStream, tarMagicNumberOffset);
IOUtils.write(tarMagicNumber, tarFileAStream, StandardCharsets.UTF_8);
}
@@ -843,7 +843,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!randomFileB.getParentFile().exists()) {
fail("Cannot create file " + randomFileB + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(randomFileB.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(randomFileB.toPath()))) {
TestUtils.generateTestData(output, 2 * tarMagicNumberOffset);
}
@@ -885,7 +885,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output2, 0);
}
assertFiltering(filter1, file, true);
@@ -895,7 +895,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output1, 0);
}
assertFiltering(filter1, file, true);
@@ -905,7 +905,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output, 0);
}
assertFiltering(filter1, file, true);
@@ -933,13 +933,13 @@ public class FileFilterTest extends AbstractFilterTest {
if (!fileA.getParentFile().exists()) {
fail("Cannot create file " + fileA + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(fileA.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(fileA.toPath()))) {
TestUtils.generateTestData(output1, 32);
}
if (!fileB.getParentFile().exists()) {
fail("Cannot create file " + fileB + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(fileB.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(fileB.toPath()))) {
TestUtils.generateTestData(output, 32);
}
@@ -972,13 +972,13 @@ public class FileFilterTest extends AbstractFilterTest {
if (!fileA.getParentFile().exists()) {
fail("Cannot create file " + fileA + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(fileA.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(fileA.toPath()))) {
TestUtils.generateTestData(output1, 32);
}
if (!fileB.getParentFile().exists()) {
fail("Cannot create file " + fileB + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(fileB.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(fileB.toPath()))) {
TestUtils.generateTestData(output, 32);
}
@@ -1004,7 +1004,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output2 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output2, 0);
}
assertFiltering(filter1, file, true);
@@ -1014,7 +1014,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output1, 0);
}
assertFiltering(filter1, file, true);
@@ -1024,7 +1024,7 @@ public class FileFilterTest extends AbstractFilterTest {
if (!file.getParentFile().exists()) {
fail("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output, 0);
}
assertFiltering(filter1, file, true);
@@ -1225,14 +1225,14 @@ public class FileFilterTest extends AbstractFilterTest {
if (!smallFile.getParentFile().exists()) {
fail("Cannot create file " + smallFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(smallFile.toPath()))) {
+ try (BufferedOutputStream output1 = new BufferedOutputStream(Files.newOutputStream(smallFile.toPath()))) {
TestUtils.generateTestData(output1, 32);
}
final File largeFile = new File(temporaryFolder, "large.txt");
if (!largeFile.getParentFile().exists()) {
fail("Cannot create file " + largeFile + " as the parent directory does not exist");
}
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(largeFile.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(largeFile.toPath()))) {
TestUtils.generateTestData(output, 128);
}
final IOFileFilter filter1 = FileFilterUtils.sizeFileFilter(64);
diff --git a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
index e59684fa..4c0a02ae 100644
--- a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
+++ b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java
@@ -158,7 +158,7 @@ public class IOFunctionTest {
@Test
public void testIdentity() throws IOException {
final IOFunction<InputStream, InputStream> identityFunction = IOFunction.identity();
- try (final InputStream is = new ByteArrayInputStream(new byte[] { (byte) 0xa, (byte) 0xb, (byte) 0xc })) {
+ try (InputStream is = new ByteArrayInputStream(new byte[] { (byte) 0xa, (byte) 0xb, (byte) 0xc })) {
assertEquals(is, identityFunction.apply(is));
}
}
diff --git a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
index 7841c4f6..cc79dc56 100644
--- a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
@@ -155,7 +155,7 @@ public class BOMInputStreamTest {
private boolean doesSaxSupportCharacterSet(final String charSetName) throws ParserConfigurationException, SAXException, IOException {
final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- try (final StringInputStream byteStream = new StringInputStream("<?xml version=\"1.0\" encoding=\"" + charSetName + "\"?><Z/>", charSetName)) {
+ try (StringInputStream byteStream = new StringInputStream("<?xml version=\"1.0\" encoding=\"" + charSetName + "\"?><Z/>", charSetName)) {
final InputSource is = new InputSource(byteStream);
is.setEncoding(charSetName);
documentBuilder.parse(is);
@@ -184,9 +184,9 @@ public class BOMInputStreamTest {
}
private void readBOMInputStreamTwice(final String resource) throws Exception {
- try (final InputStream inputStream = this.getClass().getResourceAsStream(resource)) {
+ try (InputStream inputStream = this.getClass().getResourceAsStream(resource)) {
assertNotNull(inputStream);
- try (final BOMInputStream bomInputStream = new BOMInputStream(inputStream)) {
+ try (BOMInputStream bomInputStream = new BOMInputStream(inputStream)) {
bomInputStream.mark(1000000);
this.readFile(bomInputStream);
@@ -208,7 +208,7 @@ public class BOMInputStreamTest {
@Test
public void skipReturnValueWithBom() throws IOException {
final byte[] baseData = { (byte) 0x31, (byte) 0x32, (byte) 0x33 };
- try (final BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true))) {
+ try (BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true))) {
assertEquals(2, is1.skip(2));
assertEquals((byte) 0x33, is1.read());
}
@@ -217,7 +217,7 @@ public class BOMInputStreamTest {
@Test
public void skipReturnValueWithoutBom() throws IOException {
final byte[] baseData = { (byte) 0x31, (byte) 0x32, (byte) 0x33 };
- try (final BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false))) {
+ try (BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false))) {
assertEquals(2, is2.skip(2)); // IO-428
assertEquals((byte) 0x33, is2.read());
}
@@ -226,7 +226,7 @@ public class BOMInputStreamTest {
@Test
public void testAvailableWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
assertEquals(7, in.available());
}
}
@@ -234,7 +234,7 @@ public class BOMInputStreamTest {
@Test
public void testAvailableWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertEquals(4, in.available());
}
}
@@ -242,8 +242,8 @@ public class BOMInputStreamTest {
@Test
// this is here for coverage
public void testClose() throws Exception {
- try (final ExpectCloseInputStream del = new ExpectCloseInputStream()) {
- try (final InputStream in = new BOMInputStream(del)) {
+ try (ExpectCloseInputStream del = new ExpectCloseInputStream()) {
+ try (InputStream in = new BOMInputStream(del)) {
// nothing
}
del.assertCloseCalled();
@@ -253,7 +253,7 @@ public class BOMInputStreamTest {
@Test
public void testEmptyBufferWithBOM() throws Exception {
final byte[] data = {};
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
final byte[] buf = new byte[1024];
assertEquals(-1, in.read(buf));
}
@@ -262,7 +262,7 @@ public class BOMInputStreamTest {
@Test
public void testEmptyBufferWithoutBOM() throws Exception {
final byte[] data = {};
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
final byte[] buf = new byte[1024];
assertEquals(-1, in.read(buf));
}
@@ -271,7 +271,7 @@ public class BOMInputStreamTest {
@Test
public void testGetBOMFirstThenRead() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
assertEquals(ByteOrderMark.UTF_8, in.getBOM(), "getBOM");
assertTrue(in.hasBOM(), "hasBOM()");
assertTrue(in.hasBOM(ByteOrderMark.UTF_8), "hasBOM(UTF-8)");
@@ -285,7 +285,7 @@ public class BOMInputStreamTest {
@Test
public void testGetBOMFirstThenReadInclude() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true)) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true)) {
assertTrue(in.hasBOM(), "hasBOM()");
assertTrue(in.hasBOM(ByteOrderMark.UTF_8), "hasBOM(UTF-8)");
assertEquals(ByteOrderMark.UTF_8, in.getBOM(), "getBOM");
@@ -302,7 +302,7 @@ public class BOMInputStreamTest {
@Test
public void testLargeBufferWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
final byte[] buf = new byte[1024];
assertData(data, buf, in.read(buf));
}
@@ -311,7 +311,7 @@ public class BOMInputStreamTest {
@Test
public void testLargeBufferWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
final byte[] buf = new byte[1024];
assertData(data, buf, in.read(buf));
}
@@ -320,7 +320,7 @@ public class BOMInputStreamTest {
@Test
public void testLeadingNonBOMBufferedRead() throws Exception {
final byte[] data = { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
final byte[] buf = new byte[1024];
assertData(data, buf, in.read(buf));
}
@@ -329,7 +329,7 @@ public class BOMInputStreamTest {
@Test
public void testLeadingNonBOMSingleRead() throws Exception {
final byte[] data = { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertEquals(0xEF, in.read());
assertEquals(0xAB, in.read());
assertEquals(0xCD, in.read());
@@ -340,7 +340,7 @@ public class BOMInputStreamTest {
@Test
public void testMarkResetAfterReadWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
assertTrue(in.markSupported());
in.read();
@@ -356,7 +356,7 @@ public class BOMInputStreamTest {
@Test
public void testMarkResetAfterReadWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertTrue(in.markSupported());
in.read();
@@ -372,7 +372,7 @@ public class BOMInputStreamTest {
@Test
public void testMarkResetBeforeReadWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
assertTrue(in.markSupported());
in.mark(10);
@@ -387,7 +387,7 @@ public class BOMInputStreamTest {
@Test
public void testMarkResetBeforeReadWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertTrue(in.markSupported());
in.mark(10);
@@ -409,7 +409,7 @@ public class BOMInputStreamTest {
@Test
public void testReadEmpty() throws Exception {
final byte[] data = {};
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertEquals(-1, in.read());
assertFalse(in.hasBOM(), "hasBOM()");
assertFalse(in.hasBOM(ByteOrderMark.UTF_8), "hasBOM(UTF-8)");
@@ -420,7 +420,7 @@ public class BOMInputStreamTest {
@Test
public void testReadSmall() throws Exception {
final byte[] data = { 'A', 'B' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertEquals('A', in.read());
assertEquals('B', in.read());
assertEquals(-1, in.read());
@@ -443,7 +443,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithBOMInclude() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true)) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true)) {
assertEquals(0xEF, in.read());
assertEquals(0xBB, in.read());
assertEquals(0xBF, in.read());
@@ -460,7 +460,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithBOMUtf16Be() throws Exception {
final byte[] data = "ABC".getBytes(StandardCharsets.UTF_16BE);
- try (final BOMInputStream in = new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_16BE)) {
+ try (BOMInputStream in = new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_16BE)) {
assertEquals(0, in.read());
assertEquals('A', in.read());
assertEquals(0, in.read());
@@ -478,7 +478,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithBOMUtf16Le() throws Exception {
final byte[] data = "ABC".getBytes(StandardCharsets.UTF_16LE);
- try (final BOMInputStream in = new BOMInputStream(createUtf16LeDataStream(data, true), ByteOrderMark.UTF_16LE)) {
+ try (BOMInputStream in = new BOMInputStream(createUtf16LeDataStream(data, true), ByteOrderMark.UTF_16LE)) {
assertEquals('A', in.read());
assertEquals(0, in.read());
assertEquals('B', in.read());
@@ -497,7 +497,7 @@ public class BOMInputStreamTest {
public void testReadWithBOMUtf32Be() throws Exception {
assumeTrue(Charset.isSupported("UTF_32BE"));
final byte[] data = "ABC".getBytes("UTF_32BE");
- try (final BOMInputStream in = new BOMInputStream(createUtf32BeDataStream(data, true),
+ try (BOMInputStream in = new BOMInputStream(createUtf32BeDataStream(data, true),
ByteOrderMark.UTF_32BE)) {
assertEquals(0, in.read());
assertEquals(0, in.read());
@@ -523,7 +523,7 @@ public class BOMInputStreamTest {
public void testReadWithBOMUtf32Le() throws Exception {
assumeTrue(Charset.isSupported("UTF_32LE"));
final byte[] data = "ABC".getBytes("UTF_32LE");
- try (final BOMInputStream in = new BOMInputStream(createUtf32LeDataStream(data, true),
+ try (BOMInputStream in = new BOMInputStream(createUtf32LeDataStream(data, true),
ByteOrderMark.UTF_32LE)) {
assertEquals('A', in.read());
assertEquals(0, in.read());
@@ -548,7 +548,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithBOMUtf8() throws Exception {
final byte[] data = "ABC".getBytes(StandardCharsets.UTF_8);
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), ByteOrderMark.UTF_8)) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), ByteOrderMark.UTF_8)) {
assertEquals('A', in.read());
assertEquals('B', in.read());
assertEquals('C', in.read());
@@ -563,7 +563,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithMultipleBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), ByteOrderMark.UTF_16BE,
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), ByteOrderMark.UTF_16BE,
ByteOrderMark.UTF_8)) {
assertEquals('A', in.read());
assertEquals('B', in.read());
@@ -579,7 +579,7 @@ public class BOMInputStreamTest {
@Test
public void testReadWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
assertEquals('A', in.read());
assertEquals('B', in.read());
assertEquals('C', in.read());
@@ -695,7 +695,7 @@ public class BOMInputStreamTest {
@Test
public void testSkipWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
in.skip(2L);
assertEquals('C', in.read());
}
@@ -704,7 +704,7 @@ public class BOMInputStreamTest {
@Test
public void testSkipWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C', 'D' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
in.skip(2L);
assertEquals('C', in.read());
}
@@ -713,7 +713,7 @@ public class BOMInputStreamTest {
@Test
public void testSmallBufferWithBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, true))) {
final byte[] buf = new byte[1024];
assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2));
assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2));
@@ -723,7 +723,7 @@ public class BOMInputStreamTest {
@Test
public void testSmallBufferWithoutBOM() throws Exception {
final byte[] data = { 'A', 'B', 'C' };
- try (final InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
+ try (InputStream in = new BOMInputStream(createUtf8DataStream(data, false))) {
final byte[] buf = new byte[1024];
assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2));
assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2));
@@ -733,7 +733,7 @@ public class BOMInputStreamTest {
@Test
// make sure that our support code works as expected
public void testSupportCode() throws Exception {
- try (final InputStream in = createUtf8DataStream(new byte[] { 'A', 'B' }, true)) {
+ try (InputStream in = createUtf8DataStream(new byte[] { 'A', 'B' }, true)) {
final byte[] buf = new byte[1024];
final int len = in.read(buf);
assertEquals(5, len);
diff --git a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
index 465c70b5..b45d924a 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java
@@ -50,7 +50,7 @@ public class BoundedReaderTest {
@Test
public void closeTest() throws IOException {
final AtomicBoolean closed = new AtomicBoolean(false);
- try (final Reader sr = new BufferedReader(new StringReader("01234567890")) {
+ try (Reader sr = new BufferedReader(new StringReader("01234567890")) {
@Override
public void close() throws IOException {
closed.set(true);
@@ -58,7 +58,7 @@ public class BoundedReaderTest {
}
}) {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
// nothing
}
}
@@ -67,7 +67,7 @@ public class BoundedReaderTest {
@Test
public void markReset() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.mark(3);
mr.read();
mr.read();
@@ -82,7 +82,7 @@ public class BoundedReaderTest {
@Test
public void markResetFromOffset1() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.mark(3);
mr.read();
mr.read();
@@ -97,7 +97,7 @@ public class BoundedReaderTest {
@Test
public void markResetMarkMore() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.mark(4);
mr.read();
mr.read();
@@ -112,7 +112,7 @@ public class BoundedReaderTest {
@Test
public void markResetWithMarkOutsideBoundedReaderMax() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.mark(4);
mr.read();
mr.read();
@@ -123,7 +123,7 @@ public class BoundedReaderTest {
@Test
public void markResetWithMarkOutsideBoundedReaderMaxAndInitialOffset() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.read();
mr.mark(3);
mr.read();
@@ -134,7 +134,7 @@ public class BoundedReaderTest {
@Test
public void readMulti() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
final char[] cbuf = new char[4];
Arrays.fill(cbuf, 'X');
final int read = mr.read(cbuf, 0, 4);
@@ -148,7 +148,7 @@ public class BoundedReaderTest {
@Test
public void readMultiWithOffset() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
final char[] cbuf = new char[4];
Arrays.fill(cbuf, 'X');
final int read = mr.read(cbuf, 1, 2);
@@ -162,7 +162,7 @@ public class BoundedReaderTest {
@Test
public void readTillEnd() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.read();
mr.read();
mr.read();
@@ -172,7 +172,7 @@ public class BoundedReaderTest {
@Test
public void shortReader() throws IOException {
- try (final BoundedReader mr = new BoundedReader(shortReader, 3)) {
+ try (BoundedReader mr = new BoundedReader(shortReader, 3)) {
mr.read();
mr.read();
assertEquals(-1, mr.read());
@@ -181,7 +181,7 @@ public class BoundedReaderTest {
@Test
public void skipTest() throws IOException {
- try (final BoundedReader mr = new BoundedReader(sr, 3)) {
+ try (BoundedReader mr = new BoundedReader(sr, 3)) {
mr.skip(2);
mr.read();
assertEquals(-1, mr.read());
@@ -197,7 +197,7 @@ public class BoundedReaderTest {
}
public void testLineNumberReaderAndFileReaderLastLine(final String data) throws IOException {
- try (final TempFile path = TempFile.create(getClass().getSimpleName(), ".txt")) {
+ try (TempFile path = TempFile.create(getClass().getSimpleName(), ".txt")) {
final File file = path.toFile();
FileUtils.write(file, data, StandardCharsets.ISO_8859_1);
try (Reader source = Files.newBufferedReader(file.toPath())) {
diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
index 0f34c07d..6c146bf7 100644
--- a/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java
@@ -197,7 +197,7 @@ public class CharSequenceInputStreamTest {
private void testIO_356(final int bufferSize, final int dataSize, final int readFirst, final String csName) throws Exception {
final byte[] data1;
final byte[] data2;
- try (final CharSequenceInputStream is = new CharSequenceInputStream(ALPHABET, csName, bufferSize)) {
+ try (CharSequenceInputStream is = new CharSequenceInputStream(ALPHABET, csName, bufferSize)) {
for (int i = 0; i < readFirst; i++) {
final int ch = is.read();
assertNotEquals(-1, ch);
diff --git a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
index 8ba0e0b4..12296f34 100644
--- a/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
@@ -75,7 +75,7 @@ public class CharSequenceReaderTest {
@Test
public void testMark() throws IOException {
- try (final Reader reader = new CharSequenceReader("FooBar")) {
+ try (Reader reader = new CharSequenceReader("FooBar")) {
checkRead(reader, "Foo");
reader.mark(0);
checkRead(reader, "Bar");
@@ -86,7 +86,7 @@ public class CharSequenceReaderTest {
reader.reset();
checkRead(reader, "Foo");
}
- try (final Reader subReader = new CharSequenceReader("xFooBarx", 1, 7)) {
+ try (Reader subReader = new CharSequenceReader("xFooBarx", 1, 7)) {
checkRead(subReader, "Foo");
subReader.mark(0);
checkRead(subReader, "Bar");
@@ -101,7 +101,7 @@ public class CharSequenceReaderTest {
@Test
public void testMarkSupported() throws Exception {
- try (final Reader reader = new CharSequenceReader("FooBar")) {
+ try (Reader reader = new CharSequenceReader("FooBar")) {
assertTrue(reader.markSupported());
}
}
@@ -116,14 +116,14 @@ public class CharSequenceReaderTest {
}
private void testRead(final CharSequence charSequence) throws IOException {
- try (final Reader reader = new CharSequenceReader(charSequence)) {
+ try (Reader reader = new CharSequenceReader(charSequence)) {
assertEquals('F', reader.read());
assertEquals('o', reader.read());
assertEquals('o', reader.read());
assertEquals(-1, reader.read());
assertEquals(-1, reader.read());
}
- try (final Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
+ try (Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
assertEquals('o', reader.read());
assertEquals('o', reader.read());
assertEquals(-1, reader.read());
@@ -141,7 +141,7 @@ public class CharSequenceReaderTest {
}
private void testReadCharArray(final CharSequence charSequence) throws IOException {
- try (final Reader reader = new CharSequenceReader(charSequence)) {
+ try (Reader reader = new CharSequenceReader(charSequence)) {
char[] chars = new char[2];
assertEquals(2, reader.read(chars));
checkArray(new char[] { 'F', 'o' }, chars);
@@ -153,7 +153,7 @@ public class CharSequenceReaderTest {
checkArray(new char[] { 'r', NONE, NONE }, chars);
assertEquals(-1, reader.read(chars));
}
- try (final Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
+ try (Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
char[] chars = new char[2];
assertEquals(2, reader.read(chars));
checkArray(new char[] { 'o', 'o' }, chars);
@@ -178,7 +178,7 @@ public class CharSequenceReaderTest {
private void testReadCharArrayPortion(final CharSequence charSequence) throws IOException {
final char[] chars = new char[10];
- try (final Reader reader = new CharSequenceReader(charSequence)) {
+ try (Reader reader = new CharSequenceReader(charSequence)) {
assertEquals(3, reader.read(chars, 3, 3));
checkArray(new char[] { NONE, NONE, NONE, 'F', 'o', 'o' }, chars);
assertEquals(3, reader.read(chars, 0, 3));
@@ -186,7 +186,7 @@ public class CharSequenceReaderTest {
assertEquals(-1, reader.read(chars));
}
Arrays.fill(chars, NONE);
- try (final Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
+ try (Reader reader = new CharSequenceReader(charSequence, 1, 5)) {
assertEquals(2, reader.read(chars, 3, 2));
checkArray(new char[] { NONE, NONE, NONE, 'o', 'o', NONE }, chars);
assertEquals(2, reader.read(chars, 0, 3));
diff --git a/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java b/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java
index 670a98b8..1e14f3f1 100644
--- a/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/CharacterSetFilterReaderTest.java
@@ -64,7 +64,7 @@ public class CharacterSetFilterReaderTest {
try (StringReader input = new StringReader("a")) {
final HashSet<Integer> codePoints = new HashSet<>();
codePoints.add(Integer.valueOf('a'));
- try (final CharacterSetFilterReader reader = new CharacterSetFilterReader(input, codePoints)) {
+ try (CharacterSetFilterReader reader = new CharacterSetFilterReader(input, codePoints)) {
assertEquals(-1, reader.read());
}
}
diff --git a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
index e38ad26c..a57ccbfc 100644
--- a/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java
@@ -89,7 +89,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.writeObject(input);
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final Object result = clois.readObject();
@@ -107,7 +107,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.writeObject(input);
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final Object result = clois.readObject();
@@ -126,7 +126,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.close();
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final Object result = clois.readObject();
@@ -145,7 +145,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.close();
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final Object result = clois.readObject();
@@ -164,7 +164,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.close();
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final long result = clois.readLong();
@@ -180,7 +180,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.writeObject(Boolean.FALSE);
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final String[] interfaces = { Comparable.class.getName() };
final Class<?> result = clois.resolveProxyClass(interfaces);
@@ -196,7 +196,7 @@ public class ClassLoaderObjectInputStreamTest {
oos.writeObject(Boolean.FALSE);
final InputStream bais = new ByteArrayInputStream(baos.toByteArray());
- try (final ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
+ try (ClassLoaderObjectInputStream clois = new ClassLoaderObjectInputStream(getClass().getClassLoader(),
bais)) {
final String[] interfaces = { Comparable.class.getName(), Serializable.class.getName(),
Runnable.class.getName() };
diff --git a/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java
index 11dc38a9..6a4d685e 100644
--- a/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java
@@ -27,7 +27,7 @@ public class ClosedInputStreamTest {
@Test
public void testRead() throws Exception {
- try (final ClosedInputStream cis = new ClosedInputStream()) {
+ try (ClosedInputStream cis = new ClosedInputStream()) {
assertEquals(-1, cis.read(), "read()");
}
}
diff --git a/src/test/java/org/apache/commons/io/input/ClosedReaderTest.java b/src/test/java/org/apache/commons/io/input/ClosedReaderTest.java
index 0faad8d4..2c9debc3 100644
--- a/src/test/java/org/apache/commons/io/input/ClosedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/ClosedReaderTest.java
@@ -27,7 +27,7 @@ public class ClosedReaderTest {
@Test
public void testRead() throws Exception {
- try (final ClosedReader cr = new ClosedReader()) {
+ try (ClosedReader cr = new ClosedReader()) {
assertEquals(-1, cr.read(new char[10], 0, 10), "read(cbuf, off, len)");
}
}
diff --git a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
index 3eb726a5..abd8bf2e 100644
--- a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
@@ -34,7 +34,7 @@ public class CountingInputStreamTest {
@Test
public void testCounting() throws Exception {
final String text = "A piece of text";
- try (final CountingInputStream cis = new CountingInputStream(new StringInputStream(text))) {
+ try (CountingInputStream cis = new CountingInputStream(new StringInputStream(text))) {
// have to declare this larger as we're going to read
// off the end of the stream and input stream seems
@@ -67,7 +67,7 @@ public class CountingInputStreamTest {
@Test
public void testEOF1() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
int found = cis.read();
assertEquals(0, found);
@@ -84,7 +84,7 @@ public class CountingInputStreamTest {
@Test
public void testEOF2() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final byte[] result = new byte[10];
@@ -97,7 +97,7 @@ public class CountingInputStreamTest {
@Test
public void testEOF3() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final byte[] result = new byte[10];
@@ -134,7 +134,7 @@ public class CountingInputStreamTest {
final String text = "A piece of text";
final byte[] bytes = text.getBytes();
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final byte[] result = new byte[bytes.length];
@@ -150,7 +150,7 @@ public class CountingInputStreamTest {
@Test
public void testSkipping() throws IOException {
final String text = "Hello World!";
- try (final CountingInputStream cis = new CountingInputStream(new StringInputStream(text))) {
+ try (CountingInputStream cis = new CountingInputStream(new StringInputStream(text))) {
assertEquals(6, cis.skip(6));
assertEquals(6, cis.getCount());
@@ -165,7 +165,7 @@ public class CountingInputStreamTest {
@Test
public void testZeroLength1() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final int found = cis.read();
assertEquals(-1, found);
@@ -176,7 +176,7 @@ public class CountingInputStreamTest {
@Test
public void testZeroLength2() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final byte[] result = new byte[10];
@@ -189,7 +189,7 @@ public class CountingInputStreamTest {
@Test
public void testZeroLength3() throws Exception {
final ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY);
- try (final CountingInputStream cis = new CountingInputStream(bais)) {
+ try (CountingInputStream cis = new CountingInputStream(bais)) {
final byte[] result = new byte[10];
diff --git a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
index 5edb9ec6..b4c6f423 100644
--- a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java
@@ -50,7 +50,7 @@ public class MarkShieldInputStreamTest {
@Test
public void markIsNoOpWhenUnderlyingDoesNotSupport() throws IOException {
- try (final MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(64, false, false));
+ try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(64, false, false));
final MarkShieldInputStream msis = new MarkShieldInputStream(in)) {
msis.mark(1024);
@@ -62,7 +62,7 @@ public class MarkShieldInputStreamTest {
@Test
public void markIsNoOpWhenUnderlyingSupports() throws IOException {
- try (final MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(64, true, false));
+ try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(64, true, false));
final MarkShieldInputStream msis = new MarkShieldInputStream(in)) {
msis.mark(1024);
@@ -75,10 +75,10 @@ public class MarkShieldInputStreamTest {
@Test
public void markSupportedIsFalseWhenUnderlyingFalse() throws IOException {
// test wrapping an underlying stream which does NOT support marking
- try (final InputStream is = new NullInputStream(64, false, false)) {
+ try (InputStream is = new NullInputStream(64, false, false)) {
assertFalse(is.markSupported());
- try (final MarkShieldInputStream msis = new MarkShieldInputStream(is)) {
+ try (MarkShieldInputStream msis = new MarkShieldInputStream(is)) {
assertFalse(msis.markSupported());
}
}
@@ -87,10 +87,10 @@ public class MarkShieldInputStreamTest {
@Test
public void markSupportedIsFalseWhenUnderlyingTrue() throws IOException {
// test wrapping an underlying stream which supports marking
- try (final InputStream is = new NullInputStream(64, true, false)) {
+ try (InputStream is = new NullInputStream(64, true, false)) {
assertTrue(is.markSupported());
- try (final MarkShieldInputStream msis = new MarkShieldInputStream(is)) {
+ try (MarkShieldInputStream msis = new MarkShieldInputStream(is)) {
assertFalse(msis.markSupported());
}
}
@@ -99,7 +99,7 @@ public class MarkShieldInputStreamTest {
@Test
public void resetThrowsExceptionWhenUnderylingDoesNotSupport() throws IOException {
// test wrapping an underlying stream which does NOT support marking
- try (final MarkShieldInputStream msis = new MarkShieldInputStream(
+ try (MarkShieldInputStream msis = new MarkShieldInputStream(
new NullInputStream(64, false, false))) {
assertThrows(UnsupportedOperationException.class, msis::reset);
}
@@ -108,7 +108,7 @@ public class MarkShieldInputStreamTest {
@Test
public void resetThrowsExceptionWhenUnderylingSupports() throws IOException {
// test wrapping an underlying stream which supports marking
- try (final MarkShieldInputStream msis = new MarkShieldInputStream(
+ try (MarkShieldInputStream msis = new MarkShieldInputStream(
new NullInputStream(64, true, false))) {
assertThrows(UnsupportedOperationException.class, msis::reset);
}
diff --git a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
index bfd0330e..e0e611f2 100644
--- a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
@@ -42,7 +42,7 @@ public class MessageDigestCalculatingInputStreamTest {
final byte[] buffer = generateRandomByteStream(i);
final MessageDigest messageDigest = MessageDigestCalculatingInputStream.getDefaultMessageDigest();
final byte[] expect = messageDigest.digest(buffer);
- try (final MessageDigestCalculatingInputStream messageDigestInputStream = new MessageDigestCalculatingInputStream(
+ try (MessageDigestCalculatingInputStream messageDigestInputStream = new MessageDigestCalculatingInputStream(
new ByteArrayInputStream(buffer))) {
messageDigestInputStream.consume();
assertArrayEquals(expect, messageDigestInputStream.getMessageDigest().digest());
diff --git a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
index 137b2335..2fcaa030 100644
--- a/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
@@ -60,7 +60,7 @@ public class NullInputStreamTest {
@Test
public void testEOFException() throws Exception {
- try (final InputStream input = new TestNullInputStream(2, false, true)) {
+ try (InputStream input = new TestNullInputStream(2, false, true)) {
assertEquals(0, input.read(), "Read 1");
assertEquals(1, input.read(), "Read 2");
assertThrows(EOFException.class, () -> input.read());
diff --git a/src/test/java/org/apache/commons/io/input/NullReaderTest.java b/src/test/java/org/apache/commons/io/input/NullReaderTest.java
index fa1ea083..87cd2542 100644
--- a/src/test/java/org/apache/commons/io/input/NullReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/NullReaderTest.java
@@ -60,7 +60,7 @@ public class NullReaderTest {
@Test
public void testEOFException() throws Exception {
- try (final Reader reader = new TestNullReader(2, false, true)) {
+ try (Reader reader = new TestNullReader(2, false, true)) {
assertEquals(0, reader.read(), "Read 1");
assertEquals(1, reader.read(), "Read 2");
assertThrows(EOFException.class, () -> reader.read());
diff --git a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
index dc82fca4..0a0e9150 100644
--- a/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ObservableInputStreamTest.java
@@ -129,21 +129,21 @@ public class ObservableInputStreamTest {
@Test
public void testBrokenInputStreamRead() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
+ try (ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, ois::read);
}
}
@Test
public void testBrokenInputStreamReadBuffer() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
+ try (ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, () -> ois.read(new byte[1]));
}
}
@Test
public void testBrokenInputStreamReadSubBuffer() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
+ try (ObservableInputStream ois = new ObservableInputStream(BrokenInputStream.INSTANCE)) {
assertThrows(IOException.class, () -> ois.read(new byte[2], 0, 1));
}
}
@@ -156,7 +156,7 @@ public class ObservableInputStreamTest {
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
final DataViewObserver lko = new DataViewObserver();
- try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer))) {
+ try (ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer))) {
assertEquals(-1, lko.lastValue);
ois.read();
assertEquals(-1, lko.lastValue);
@@ -188,7 +188,7 @@ public class ObservableInputStreamTest {
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
final DataViewObserver lko = new DataViewObserver();
- try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer), lko)) {
+ try (ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer), lko)) {
assertEquals(-1, lko.lastValue);
ois.read();
assertNotEquals(-1, lko.lastValue);
@@ -218,7 +218,7 @@ public class ObservableInputStreamTest {
public void testDataBytesCalled() throws Exception {
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
- try (final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
final ObservableInputStream ois = new ObservableInputStream(bais)) {
final DataViewObserver observer = new DataViewObserver();
final byte[] readBuffer = new byte[23];
@@ -253,7 +253,7 @@ public class ObservableInputStreamTest {
@Test
public void testGetObservers0() throws IOException {
- try (final ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE)) {
+ try (ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE)) {
assertTrue(ois.getObservers().isEmpty());
}
}
@@ -261,7 +261,7 @@ public class ObservableInputStreamTest {
@Test
public void testGetObservers1() throws IOException {
final DataViewObserver observer0 = new DataViewObserver();
- try (final ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE, observer0)) {
+ try (ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE, observer0)) {
assertEquals(observer0, ois.getObservers().get(0));
}
}
@@ -270,7 +270,7 @@ public class ObservableInputStreamTest {
public void testGetObserversOrder() throws IOException {
final DataViewObserver observer0 = new DataViewObserver();
final DataViewObserver observer1 = new DataViewObserver();
- try (final ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE, observer0, observer1)) {
+ try (ObservableInputStream ois = new ObservableInputStream(NullInputStream.INSTANCE, observer0, observer1)) {
assertEquals(observer0, ois.getObservers().get(0));
assertEquals(observer1, ois.getObservers().get(1));
}
@@ -280,7 +280,7 @@ public class ObservableInputStreamTest {
final byte[] buffer = IOUtils.byteArray();
final LengthObserver lengthObserver = new LengthObserver();
final MethodCountObserver methodCountObserver = new MethodCountObserver();
- try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
+ try (ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
lengthObserver, methodCountObserver)) {
assertEquals(IOUtils.DEFAULT_BUFFER_SIZE,
IOUtils.copy(ois, NullOutputStream.INSTANCE, bufferSize));
diff --git a/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java b/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
index fd808c53..b176d480 100644
--- a/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
@@ -53,7 +53,7 @@ public class ProxyReaderTest {
@Test
public void testNullCharArray() throws Exception {
- try (final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0))) {
+ try (ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0))) {
proxy.read((char[]) null);
proxy.read(null, 0, 0);
}
@@ -61,7 +61,7 @@ public class ProxyReaderTest {
@Test
public void testNullCharBuffer() throws Exception {
- try (final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0))) {
+ try (ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0))) {
proxy.read((CharBuffer) null);
}
}
diff --git a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
index 8cc83c46..6cf50ab6 100644
--- a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
@@ -65,7 +65,7 @@ public class QueueInputStreamTest {
@MethodSource("inputData")
public void bufferedReads(final String inputData) throws IOException {
final BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
- try (final BufferedInputStream inputStream = new BufferedInputStream(new QueueInputStream(queue));
+ try (BufferedInputStream inputStream = new BufferedInputStream(new QueueInputStream(queue));
final QueueOutputStream outputStream = new QueueOutputStream(queue)) {
outputStream.write(inputData.getBytes(UTF_8));
final String actualData = IOUtils.toString(inputStream, UTF_8);
@@ -77,7 +77,7 @@ public class QueueInputStreamTest {
@MethodSource("inputData")
public void bufferedReadWrite(final String inputData) throws IOException {
final BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
- try (final BufferedInputStream inputStream = new BufferedInputStream(new QueueInputStream(queue));
+ try (BufferedInputStream inputStream = new BufferedInputStream(new QueueInputStream(queue));
final BufferedOutputStream outputStream = new BufferedOutputStream(new QueueOutputStream(queue), defaultBufferSize())) {
outputStream.write(inputData.getBytes(UTF_8));
outputStream.flush();
@@ -90,7 +90,7 @@ public class QueueInputStreamTest {
@MethodSource("inputData")
public void bufferedWrites(final String inputData) throws IOException {
final BlockingQueue<Integer> queue = new LinkedBlockingQueue<>();
- try (final QueueInputStream inputStream = new QueueInputStream(queue);
+ try (QueueInputStream inputStream = new QueueInputStream(queue);
final BufferedOutputStream outputStream = new BufferedOutputStream(new QueueOutputStream(queue), defaultBufferSize())) {
outputStream.write(inputData.getBytes(UTF_8));
outputStream.flush();
@@ -120,7 +120,7 @@ public class QueueInputStreamTest {
@ParameterizedTest(name = "inputData={0}")
@MethodSource("inputData")
public void unbufferedReadWrite(final String inputData) throws IOException {
- try (final QueueInputStream inputStream = new QueueInputStream();
+ try (QueueInputStream inputStream = new QueueInputStream();
final QueueOutputStream outputStream = inputStream.newQueueOutputStream()) {
writeUnbuffered(outputStream, inputData);
final String actualData = readUnbuffered(inputStream);
diff --git a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
index 86fbd5e3..7622e61b 100644
--- a/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/RandomAccessFileInputStreamTest.java
@@ -42,7 +42,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testAvailable() throws IOException {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
true)) {
assertEquals(DATA_FILE_LEN, inputStream.available());
}
@@ -50,7 +50,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testAvailableLong() throws IOException {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
true)) {
assertEquals(DATA_FILE_LEN, inputStream.availableLong());
}
@@ -59,7 +59,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testCtorCloseOnCloseFalse() throws IOException {
try (RandomAccessFile file = createRandomAccessFile()) {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, false)) {
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, false)) {
assertFalse(inputStream.isCloseOnClose());
}
file.read();
@@ -69,7 +69,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testCtorCloseOnCloseTrue() throws IOException {
try (RandomAccessFile file = createRandomAccessFile()) {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, true)) {
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, true)) {
assertTrue(inputStream.isCloseOnClose());
}
assertThrows(IOException.class, file::read);
@@ -84,7 +84,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testGetters() throws IOException {
try (RandomAccessFile file = createRandomAccessFile()) {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, true)) {
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, true)) {
assertEquals(file, inputStream.getRandomAccessFile());
assertTrue(inputStream.isCloseOnClose());
}
@@ -93,7 +93,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testRead() throws IOException {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
true)) {
// A Test Line.
assertEquals('A', inputStream.read());
@@ -115,7 +115,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testReadByteArray() throws IOException {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
true)) {
// A Test Line.
final int dataLen = 12;
@@ -130,7 +130,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testReadByteArrayBounds() throws IOException {
- try (final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
+ try (RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(createRandomAccessFile(),
true)) {
// A Test Line.
final int dataLen = 12;
@@ -146,7 +146,7 @@ public class RandomAccessFileInputStreamTest {
@Test
public void testSkip() throws IOException {
- try (final RandomAccessFile file = createRandomAccessFile();
+ try (RandomAccessFile file = createRandomAccessFile();
final RandomAccessFileInputStream inputStream = new RandomAccessFileInputStream(file, false)) {
assertEquals(0, inputStream.skip(-1));
assertEquals(0, inputStream.skip(Integer.MIN_VALUE));
diff --git a/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java b/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
index 1731ce09..96e43b95 100644
--- a/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
@@ -167,7 +167,7 @@ public class ReaderInputStreamTest {
@Test
public void testReadZero() throws Exception {
final String inStr = "test";
- try (final ReaderInputStream inputStream = new ReaderInputStream(new StringReader(inStr))) {
+ try (ReaderInputStream inputStream = new ReaderInputStream(new StringReader(inStr))) {
final byte[] bytes = new byte[30];
assertEquals(0, inputStream.read(bytes, 0, 0));
assertEquals(inStr.length(), inputStream.read(bytes, 0, inStr.length() + 1));
@@ -179,7 +179,7 @@ public class ReaderInputStreamTest {
@SuppressWarnings("deprecation")
@Test
public void testReadZeroEmptyString() throws Exception {
- try (final ReaderInputStream inputStream = new ReaderInputStream(new StringReader(""))) {
+ try (ReaderInputStream inputStream = new ReaderInputStream(new StringReader(""))) {
final byte[] bytes = new byte[30];
// Should always return 0 for length == 0
assertEquals(0, inputStream.read(bytes, 0, 0));
@@ -206,7 +206,7 @@ public class ReaderInputStreamTest {
private void testWithBufferedRead(final String testString, final String charsetName) throws IOException {
final byte[] expected = testString.getBytes(charsetName);
- try (final ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName)) {
+ try (ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName)) {
final byte[] buffer = new byte[128];
int offset = 0;
while (true) {
@@ -231,7 +231,7 @@ public class ReaderInputStreamTest {
private void testWithSingleByteRead(final String testString, final String charsetName) throws IOException {
final byte[] bytes = testString.getBytes(charsetName);
- try (final ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName)) {
+ try (ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName)) {
for (final byte b : bytes) {
final int read = in.read();
assertTrue(read >= 0);
diff --git a/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java b/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java
index 1f9ba54e..0b4f4667 100644
--- a/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/SequenceReaderTest.java
@@ -57,7 +57,7 @@ public class SequenceReaderTest {
@Test
public void testClose() throws IOException {
- try (final Reader reader = new SequenceReader(new CharSequenceReader("FooBar"))) {
+ try (Reader reader = new SequenceReader(new CharSequenceReader("FooBar"))) {
checkRead(reader, "Foo");
reader.close();
checkReadEof(reader);
@@ -66,14 +66,14 @@ public class SequenceReaderTest {
@Test
public void testMarkSupported() throws Exception {
- try (final Reader reader = new SequenceReader()) {
+ try (Reader reader = new SequenceReader()) {
assertFalse(reader.markSupported());
}
}
@Test
public void testRead() throws IOException {
- try (final Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
+ try (Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
assertEquals('F', reader.read());
assertEquals('o', reader.read());
assertEquals('o', reader.read());
@@ -86,7 +86,7 @@ public class SequenceReaderTest {
@Test
public void testReadCharArray() throws IOException {
- try (final Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
+ try (Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
char[] chars = new char[2];
assertEquals(2, reader.read(chars));
checkArray(new char[] { 'F', 'o' }, chars);
@@ -103,7 +103,7 @@ public class SequenceReaderTest {
@Test
public void testReadCharArrayPortion() throws IOException {
final char[] chars = new char[10];
- try (final Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
+ try (Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
assertEquals(3, reader.read(chars, 3, 3));
checkArray(new char[] { NUL, NUL, NUL, 'F', 'o', 'o' }, chars);
assertEquals(3, reader.read(chars, 0, 3));
@@ -127,7 +127,7 @@ public class SequenceReaderTest {
final Collection<Reader> readers = new ArrayList<>();
readers.add(new StringReader("F"));
readers.add(new StringReader("B"));
- try (final Reader reader = new SequenceReader(readers)) {
+ try (Reader reader = new SequenceReader(readers)) {
assertEquals('F', reader.read());
assertEquals('B', reader.read());
checkReadEof(reader);
@@ -140,7 +140,7 @@ public class SequenceReaderTest {
readers.add(new StringReader("F"));
readers.add(new StringReader("B"));
final Iterable<Reader> iterable = readers;
- try (final Reader reader = new SequenceReader(iterable)) {
+ try (Reader reader = new SequenceReader(iterable)) {
assertEquals('F', reader.read());
assertEquals('B', reader.read());
checkReadEof(reader);
@@ -149,7 +149,7 @@ public class SequenceReaderTest {
@Test
public void testReadLength0Readers() throws IOException {
- try (final Reader reader = new SequenceReader(new StringReader(StringUtils.EMPTY),
+ try (Reader reader = new SequenceReader(new StringReader(StringUtils.EMPTY),
new StringReader(StringUtils.EMPTY), new StringReader(StringUtils.EMPTY))) {
checkReadEof(reader);
}
@@ -157,7 +157,7 @@ public class SequenceReaderTest {
@Test
public void testReadLength1Readers() throws IOException {
- try (final Reader reader = new SequenceReader(
+ try (Reader reader = new SequenceReader(
// @formatter:off
new StringReader("0"),
new StringReader("1"),
@@ -176,7 +176,7 @@ public class SequenceReaderTest {
final List<Reader> readers = new ArrayList<>();
readers.add(new StringReader("F"));
readers.add(new StringReader("B"));
- try (final Reader reader = new SequenceReader(readers)) {
+ try (Reader reader = new SequenceReader(readers)) {
assertEquals('F', reader.read());
assertEquals('B', reader.read());
checkReadEof(reader);
@@ -185,7 +185,7 @@ public class SequenceReaderTest {
@Test
public void testSkip() throws IOException {
- try (final Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
+ try (Reader reader = new SequenceReader(new StringReader("Foo"), new StringReader("Bar"))) {
assertEquals(3, reader.skip(3));
checkRead(reader, "Bar");
assertEquals(0, reader.skip(3));
diff --git a/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java b/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java
index 17f43fb4..3be20412 100644
--- a/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java
@@ -33,14 +33,14 @@ public class StringInputStreamTest {
@Test
public void testStrinConstructorString() throws IOException {
- try (final StringInputStream input = StringInputStream.on("01")) {
+ try (StringInputStream input = StringInputStream.on("01")) {
assertEquals("01", IOUtils.toString(input, Charset.defaultCharset()));
}
}
@Test
public void testStrinConstructorStringCharset() throws IOException {
- try (final StringInputStream input = new StringInputStream("01", Charset.defaultCharset())) {
+ try (StringInputStream input = new StringInputStream("01", Charset.defaultCharset())) {
assertEquals("01", IOUtils.toString(input, Charset.defaultCharset()));
}
}
diff --git a/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java b/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
index d58df5b4..9360cf25 100644
--- a/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/TaggedReaderTest.java
@@ -84,7 +84,7 @@ public class TaggedReaderTest {
@Test
public void testEmptyReader() throws IOException {
- try (final Reader reader = new TaggedReader(ClosedReader.INSTANCE)) {
+ try (Reader reader = new TaggedReader(ClosedReader.INSTANCE)) {
assertFalse(reader.ready());
assertEquals(-1, reader.read());
assertEquals(-1, reader.read(new char[1]));
@@ -94,7 +94,7 @@ public class TaggedReaderTest {
@Test
public void testNormalReader() throws IOException {
- try (final Reader reader = new TaggedReader(new StringReader("abc"))) {
+ try (Reader reader = new TaggedReader(new StringReader("abc"))) {
assertTrue(reader.ready());
assertEquals('a', reader.read());
final char[] buffer = new char[1];
@@ -109,7 +109,7 @@ public class TaggedReaderTest {
@Test
public void testOtherException() throws Exception {
final IOException exception = new IOException("test exception");
- try (final TaggedReader reader = new TaggedReader(ClosedReader.INSTANCE)) {
+ try (TaggedReader reader = new TaggedReader(ClosedReader.INSTANCE)) {
assertFalse(reader.isCauseOf(exception));
assertFalse(reader.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));
diff --git a/src/test/java/org/apache/commons/io/input/TailerTest.java b/src/test/java/org/apache/commons/io/input/TailerTest.java
index 6c2f8254..5369b759 100644
--- a/src/test/java/org/apache/commons/io/input/TailerTest.java
+++ b/src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -193,7 +193,7 @@ public class TailerTest {
protected void createFile(final File file, final long size) throws IOException {
assertTrue(file.getParentFile().exists(), () -> "Cannot create file " + file + " as the parent directory does not exist");
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
TestUtils.generateTestData(output, size);
}
@@ -245,7 +245,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start-with-reopen-and-buffersize-and-charset.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer.Builder(new NonStandardTailable(file), listener).build()) {
+ try (Tailer tailer = new Tailer.Builder(new NonStandardTailable(file), listener).build()) {
assertTrue(tailer.getTailable() instanceof NonStandardTailable);
validateTailer(listener, tailer, file);
}
@@ -256,7 +256,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener)) {
+ try (Tailer tailer = Tailer.create(file, listener)) {
validateTailer(listener, tailer, file);
}
}
@@ -266,7 +266,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start-with-reopen.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, false)) {
+ try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, false)) {
validateTailer(listener, tailer, file);
}
}
@@ -276,7 +276,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS)) {
+ try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS)) {
validateTailer(listener, tailer, file);
}
}
@@ -286,7 +286,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false)) {
+ try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false)) {
validateTailer(listener, tailer, file);
}
}
@@ -296,7 +296,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start-with-buffersize.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, TEST_BUFFER_SIZE)) {
validateTailer(listener, tailer, file);
}
}
@@ -306,7 +306,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start-with-reopen-and-buffersize.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = Tailer.create(file, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
validateTailer(listener, tailer, file);
}
}
@@ -316,7 +316,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-create-with-delay-and-from-start-with-reopen-and-buffersize-and-charset.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = Tailer.create(file, StandardCharsets.UTF_8, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = Tailer.create(file, StandardCharsets.UTF_8, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
validateTailer(listener, tailer, file);
}
}
@@ -379,7 +379,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "testLongFile.txt");
createFile(file, 0);
- try (final Writer writer = Files.newBufferedWriter(file.toPath(), StandardOpenOption.APPEND)) {
+ try (Writer writer = Files.newBufferedWriter(file.toPath(), StandardOpenOption.APPEND)) {
for (int i = 0; i < 100000; i++) {
writer.write("LineLineLineLineLineLineLineLineLineLine\n");
}
@@ -451,7 +451,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener)) {
+ try (Tailer tailer = new Tailer(file, listener)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -463,7 +463,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS)) {
+ try (Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -475,7 +475,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay-and-from-start.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false)) {
+ try (Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -487,7 +487,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay-and-from-start-with-buffersize.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, TEST_BUFFER_SIZE)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -499,7 +499,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay-and-from-start-with-reopen.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, false)) {
+ try (Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, false)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -511,7 +511,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay-and-from-start-with-reopen-and-buffersize.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = new Tailer(file, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
@@ -523,7 +523,7 @@ public class TailerTest {
final File file = new File(temporaryFolder, "tailer-simple-constructor-with-delay-and-from-start-with-reopen-and-buffersize-and-charset.txt");
createFile(file, 0);
final TestTailerListener listener = new TestTailerListener(1);
- try (final Tailer tailer = new Tailer(file, StandardCharsets.UTF_8, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
+ try (Tailer tailer = new Tailer(file, StandardCharsets.UTF_8, listener, TEST_DELAY_MILLIS, false, true, TEST_BUFFER_SIZE)) {
final Thread thread = new Thread(tailer);
thread.start();
validateTailer(listener, tailer, file);
diff --git a/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java b/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
index 0f7c8857..0785e4a1 100644
--- a/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
+++ b/src/test/java/org/apache/commons/io/input/TimestampedObserverTest.java
@@ -45,7 +45,7 @@ public class TimestampedObserverTest {
assertNull(timestampedObserver.getCloseInstant());
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
- try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
+ try (ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
timestampedObserver)) {
assertTrue(timestampedObserver.getOpenInstant().isAfter(before));
assertTrue(timestampedObserver.getOpenToNowDuration().toNanos() > 0);
@@ -62,7 +62,7 @@ public class TimestampedObserverTest {
final TimestampedObserver timestampedObserver = new TimestampedObserver();
final byte[] buffer = MessageDigestCalculatingInputStreamTest
.generateRandomByteStream(IOUtils.DEFAULT_BUFFER_SIZE);
- try (final ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
+ try (ObservableInputStream ois = new ObservableInputStream(new ByteArrayInputStream(buffer),
timestampedObserver)) {
//
}
diff --git a/src/test/java/org/apache/commons/io/input/UncheckedBufferedReaderTest.java b/src/test/java/org/apache/commons/io/input/UncheckedBufferedReaderTest.java
index 7c01427e..fb0f18bc 100644
--- a/src/test/java/org/apache/commons/io/input/UncheckedBufferedReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/UncheckedBufferedReaderTest.java
@@ -82,7 +82,7 @@ public class UncheckedBufferedReaderTest {
@Test
public void testRead() {
- try (final UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
+ try (UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
assertEquals('0', uncheckedReader.read());
assertEquals('1', uncheckedReader.read());
assertEquals(IOUtils.EOF, uncheckedReader.read());
@@ -92,7 +92,7 @@ public class UncheckedBufferedReaderTest {
@Test
public void testReadCharArray() {
- try (final UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
+ try (UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
final char[] array = new char[1];
assertEquals(1, uncheckedReader.read(array));
assertEquals('0', array[0]);
@@ -109,7 +109,7 @@ public class UncheckedBufferedReaderTest {
@Test
public void testReadCharArrayIndexed() {
- try (final UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
+ try (UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
final char[] array = new char[1];
assertEquals(1, uncheckedReader.read(array, 0, 1));
assertEquals('0', array[0]);
@@ -136,7 +136,7 @@ public class UncheckedBufferedReaderTest {
@Test
public void testReadCharBuffer() {
- try (final UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
+ try (UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
final CharBuffer buffer = CharBuffer.wrap(new char[1]);
assertEquals(1, uncheckedReader.read(buffer));
buffer.flip();
@@ -162,7 +162,7 @@ public class UncheckedBufferedReaderTest {
@Test
public void testReadLine() {
- try (final UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
+ try (UncheckedBufferedReader uncheckedReader = UncheckedBufferedReader.on(ucStringReader)) {
assertEquals("01", uncheckedReader.readLine());
assertEquals(IOUtils.EOF, uncheckedReader.read());
assertEquals(IOUtils.EOF, uncheckedReader.read());
diff --git a/src/test/java/org/apache/commons/io/input/UncheckedFilterInputStreamTest.java b/src/test/java/org/apache/commons/io/input/UncheckedFilterInputStreamTest.java
index 7732f9ba..2da41b5f 100644
--- a/src/test/java/org/apache/commons/io/input/UncheckedFilterInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/UncheckedFilterInputStreamTest.java
@@ -66,7 +66,7 @@ public class UncheckedFilterInputStreamTest {
@Test
public void testRead() {
- try (final UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
+ try (UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
assertEquals('0', uncheckedReader.read());
assertEquals('1', uncheckedReader.read());
assertEquals(IOUtils.EOF, uncheckedReader.read());
@@ -76,7 +76,7 @@ public class UncheckedFilterInputStreamTest {
@Test
public void testReadByteArray() {
- try (final UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
+ try (UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
final byte[] array = new byte[1];
assertEquals(1, uncheckedReader.read(array));
assertEquals('0', array[0]);
@@ -93,7 +93,7 @@ public class UncheckedFilterInputStreamTest {
@Test
public void testReadByteArrayIndexed() {
- try (final UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
+ try (UncheckedFilterInputStream uncheckedReader = UncheckedFilterInputStream.on(stringInputStream)) {
final byte[] array = new byte[1];
assertEquals(1, uncheckedReader.read(array, 0, 1));
assertEquals('0', array[0]);
diff --git a/src/test/java/org/apache/commons/io/input/UncheckedFilterReaderTest.java b/src/test/java/org/apache/commons/io/input/UncheckedFilterReaderTest.java
index a1ffed69..1c75795f 100644
--- a/src/test/java/org/apache/commons/io/input/UncheckedFilterReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/UncheckedFilterReaderTest.java
@@ -75,7 +75,7 @@ public class UncheckedFilterReaderTest {
@Test
public void testRead() {
- try (final UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
+ try (UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
assertEquals('0', uncheckedReader.read());
assertEquals('1', uncheckedReader.read());
assertEquals(IOUtils.EOF, uncheckedReader.read());
@@ -85,7 +85,7 @@ public class UncheckedFilterReaderTest {
@Test
public void testReadCharArray() {
- try (final UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
+ try (UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
final char[] array = new char[1];
assertEquals(1, uncheckedReader.read(array));
assertEquals('0', array[0]);
@@ -102,7 +102,7 @@ public class UncheckedFilterReaderTest {
@Test
public void testReadCharArrayIndexed() {
- try (final UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
+ try (UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
final char[] array = new char[1];
assertEquals(1, uncheckedReader.read(array, 0, 1));
assertEquals('0', array[0]);
@@ -129,7 +129,7 @@ public class UncheckedFilterReaderTest {
@Test
public void testReadCharBuffer() {
- try (final UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
+ try (UncheckedFilterReader uncheckedReader = UncheckedFilterReader.on(ucStringReader)) {
final CharBuffer buffer = CharBuffer.wrap(new char[1]);
assertEquals(1, uncheckedReader.read(buffer));
buffer.flip();
diff --git a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
index bd094f77..9ad0b57c 100644
--- a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
@@ -56,7 +56,7 @@ public class WindowsLineEndingInputStreamTest {
}
private String roundtrip(final String msg, final boolean ensure) throws IOException {
- try (final WindowsLineEndingInputStream lf = new WindowsLineEndingInputStream(new StringInputStream(msg, StandardCharsets.UTF_8), ensure)) {
+ try (WindowsLineEndingInputStream lf = new WindowsLineEndingInputStream(new StringInputStream(msg, StandardCharsets.UTF_8), ensure)) {
final byte[] buf = new byte[100];
final int read = lf.read(buf);
return new String(buf, 0, read, StandardCharsets.UTF_8);
diff --git a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
index 607ee1a4..542fea07 100644
--- a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
@@ -134,7 +134,7 @@ public class XmlStreamReaderTest {
for (final int element : bom) {
baos.write(element);
}
- try (final Writer writer = new OutputStreamWriter(baos, streamEnc)) {
+ try (Writer writer = new OutputStreamWriter(baos, streamEnc)) {
final String xmlDoc = getXML(bomType, xmlType, streamEnc, prologEnc);
writer.write(xmlDoc);
@@ -273,7 +273,7 @@ public class XmlStreamReaderTest {
public void testHttpContent() throws Exception {
final String encoding = "UTF-8";
final String xml = getXML("no-bom", XML3, encoding, encoding);
- try (final XmlStreamReader xmlReader = new XmlStreamReader(new StringInputStream(xml, encoding))) {
+ try (XmlStreamReader xmlReader = new XmlStreamReader(new StringInputStream(xml, encoding))) {
assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
}
@@ -326,7 +326,7 @@ public class XmlStreamReaderTest {
final String[] encodings = { "iso8859-1", "us-ascii", "utf-8" };
for (final String encoding : encodings) {
final String xml = getXML("no-bom", XML3, encoding, encoding);
- try (final ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding));
+ try (ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding));
final XmlStreamReader xmlReader = new XmlStreamReader(is)) {
assertTrue(encoding.equalsIgnoreCase(xmlReader.getEncoding()), "Check encoding : " + encoding);
assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
@@ -426,7 +426,7 @@ public class XmlStreamReaderTest {
public void testRawContent() throws Exception {
final String encoding = "UTF-8";
final String xml = getXML("no-bom", XML3, encoding, encoding);
- try (final XmlStreamReader xmlReader = new XmlStreamReader(new StringInputStream(xml, encoding))) {
+ try (XmlStreamReader xmlReader = new XmlStreamReader(new StringInputStream(xml, encoding))) {
assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
}
diff --git a/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java b/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
index 8b12299d..a08405e4 100644
--- a/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
@@ -41,7 +41,7 @@ public class CircularBufferInputStreamTest {
@Test
public void testIO683() throws IOException {
final byte[] buffer = {0, 1, -2, -2, -1, 4};
- try (final ByteArrayInputStream bais = new ByteArrayInputStream(buffer); final CircularBufferInputStream cbis = new CircularBufferInputStream(bais)) {
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(buffer); final CircularBufferInputStream cbis = new CircularBufferInputStream(bais)) {
int b;
int i = 0;
while ((b = cbis.read()) != -1) {
diff --git a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
index 8f9a993c..1127de49 100644
--- a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
+++ b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
@@ -35,7 +35,7 @@ public class XmlStreamReaderUtilitiesCompatibilityTest extends XmlStreamReaderUt
@Override
protected String calculateHttpEncoding(final String httpContentType, final String bomEnc, final String xmlGuessEnc,
final String xmlEnc, final boolean lenient, final String defaultEncoding) throws IOException {
- try (final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding)) {
+ try (MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding)) {
return mock.calculateHttpEncoding(
XmlStreamReader.getContentTypeMime(httpContentType),
XmlStreamReader.getContentTypeEncoding(httpContentType),
@@ -46,7 +46,7 @@ public class XmlStreamReaderUtilitiesCompatibilityTest extends XmlStreamReaderUt
@Override
protected String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, final String xmlEnc,
final String defaultEncoding) throws IOException {
- try (final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding)) {
+ try (MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding)) {
return mock.calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, null);
}
}
diff --git a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTest.java
index 51d20771..4217e020 100644
--- a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTest.java
@@ -131,7 +131,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testInvalidWriteLenUnder(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
assertThrows(IndexOutOfBoundsException.class, () -> baout.write(new byte[1], 0, -1));
}
}
@@ -139,7 +139,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testInvalidWriteOffsetAndLenOver(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
assertThrows(IndexOutOfBoundsException.class, () -> baout.write(new byte[1], 0, 2));
}
}
@@ -147,7 +147,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testInvalidWriteOffsetAndLenUnder(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
assertThrows(IndexOutOfBoundsException.class, () -> baout.write(new byte[1], 1, -2));
}
}
@@ -155,7 +155,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testInvalidWriteOffsetOver(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
assertThrows(IndexOutOfBoundsException.class, () -> baout.write(IOUtils.EMPTY_BYTE_ARRAY, 1, 0));
}
}
@@ -163,7 +163,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testInvalidWriteOffsetUnder(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
assertThrows(IndexOutOfBoundsException.class, () -> baout.write(null, -1, 0));
}
}
@@ -175,7 +175,7 @@ public class ByteArrayOutputStreamTest {
// The ByteArrayOutputStream is initialized with 32 bytes to match
// the original more closely for this test.
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance(32);
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance(32);
final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream()) {
// First three writes
@@ -205,7 +205,7 @@ public class ByteArrayOutputStreamTest {
// Write the commons Byte[]OutputStream to a java.io.Byte[]OutputStream
// and vice-versa to test the writeTo() method.
- try (final AbstractByteArrayOutputStream baout1 = baosFactory.newInstance(32)) {
+ try (AbstractByteArrayOutputStream baout1 = baosFactory.newInstance(32)) {
ref.writeTo(baout1);
final java.io.ByteArrayOutputStream ref1 = new java.io.ByteArrayOutputStream();
baout.writeTo(ref1);
@@ -218,7 +218,7 @@ public class ByteArrayOutputStreamTest {
// Make sure that empty ByteArrayOutputStreams really don't create garbage
// on toByteArray()
- try (final AbstractByteArrayOutputStream baos1 = baosFactory.newInstance();
+ try (AbstractByteArrayOutputStream baos1 = baosFactory.newInstance();
final AbstractByteArrayOutputStream baos2 = baosFactory.newInstance()) {
assertSame(baos1.toByteArray(), baos2.toByteArray());
}
@@ -231,10 +231,10 @@ public class ByteArrayOutputStreamTest {
public void testToBufferedInputStream(final String baosName, final IOFunction<InputStream, InputStream> toBufferedInputStreamFunction) throws IOException {
final byte data[] = {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
- try (final ByteArrayInputStream bain = new ByteArrayInputStream(data)) {
+ try (ByteArrayInputStream bain = new ByteArrayInputStream(data)) {
assertEquals(data.length, bain.available());
- try (final InputStream buffered = toBufferedInputStreamFunction.apply(bain)) {
+ try (InputStream buffered = toBufferedInputStreamFunction.apply(bain)) {
assertEquals(data.length, buffered.available());
assertArrayEquals(data, IOUtils.toByteArray(buffered));
@@ -247,10 +247,10 @@ public class ByteArrayOutputStreamTest {
@MethodSource("toBufferedInputStreamFunctionFactories")
public void testToBufferedInputStreamEmpty(final String baosName, final IOFunction<InputStream, InputStream> toBufferedInputStreamFunction)
throws IOException {
- try (final ByteArrayInputStream bain = new ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY)) {
+ try (ByteArrayInputStream bain = new ByteArrayInputStream(IOUtils.EMPTY_BYTE_ARRAY)) {
assertEquals(0, bain.available());
- try (final InputStream buffered = toBufferedInputStreamFunction.apply(bain)) {
+ try (InputStream buffered = toBufferedInputStreamFunction.apply(bain)) {
assertEquals(0, buffered.available());
}
@@ -260,7 +260,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testToInputStream(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance();
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance();
final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream()) {
// Write 8224 bytes
@@ -270,7 +270,7 @@ public class ByteArrayOutputStreamTest {
}
// Get data before more writes
- try (final InputStream in = baout.toInputStream()) {
+ try (InputStream in = baout.toInputStream()) {
byte refData[] = ref.toByteArray();
// Write some more data
@@ -282,7 +282,7 @@ public class ByteArrayOutputStreamTest {
checkByteArrays(refData, baoutData);
// Check all data written
- try (final InputStream in2 = baout.toInputStream()) {
+ try (InputStream in2 = baout.toInputStream()) {
baoutData = IOUtils.toByteArray(in2);
}
refData = ref.toByteArray();
@@ -295,7 +295,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testToInputStreamEmpty(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance();
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance();
// Get data before more writes
final InputStream in = baout.toInputStream()) {
assertEquals(0, in.available());
@@ -307,7 +307,7 @@ public class ByteArrayOutputStreamTest {
@MethodSource("baosFactories")
public void testToInputStreamWithReset(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
// Make sure reset() do not destroy InputStream returned from toInputStream()
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance();
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance();
final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream()) {
// Write 8224 bytes
@@ -317,7 +317,7 @@ public class ByteArrayOutputStreamTest {
}
// Get data before reset
- try (final InputStream in = baout.toInputStream()) {
+ try (InputStream in = baout.toInputStream()) {
byte refData[] = ref.toByteArray();
// Reset and write some new data
@@ -331,7 +331,7 @@ public class ByteArrayOutputStreamTest {
checkByteArrays(refData, baoutData);
// Check new data written after reset
- try (final InputStream in2 = baout.toInputStream()) {
+ try (InputStream in2 = baout.toInputStream()) {
baoutData = IOUtils.toByteArray(in2);
}
refData = ref.toByteArray();
@@ -344,7 +344,7 @@ public class ByteArrayOutputStreamTest {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("baosFactories")
public void testWriteZero(final String baosName, final BAOSFactory<?> baosFactory) throws IOException {
- try (final AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
+ try (AbstractByteArrayOutputStream baout = baosFactory.newInstance()) {
baout.write(IOUtils.EMPTY_BYTE_ARRAY, 0, 0);
assertTrue(true, "Dummy");
}
diff --git a/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java
index 5b4bb457..9379d679 100644
--- a/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java
@@ -32,7 +32,7 @@ public class ChunkedOutputStreamTest {
@Test
public void defaultConstructor() throws IOException {
final AtomicInteger numWrites = new AtomicInteger();
- try (final ByteArrayOutputStream baos = newByteArrayOutputStream(numWrites);
+ try (ByteArrayOutputStream baos = newByteArrayOutputStream(numWrites);
final ChunkedOutputStream chunked = new ChunkedOutputStream(baos)) {
chunked.write(new byte[1024 * 4 + 1]);
assertEquals(2, numWrites.get());
@@ -57,7 +57,7 @@ public class ChunkedOutputStreamTest {
@Test
public void write_four_chunks() throws Exception {
final AtomicInteger numWrites = new AtomicInteger();
- try (final ByteArrayOutputStream baos = newByteArrayOutputStream(numWrites);
+ try (ByteArrayOutputStream baos = newByteArrayOutputStream(numWrites);
final ChunkedOutputStream chunked = new ChunkedOutputStream(baos, 10)) {
chunked.write("0123456789012345678901234567891".getBytes());
assertEquals(4, numWrites.get());
diff --git a/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java b/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java
index 16e1209b..339dd1b7 100644
--- a/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java
@@ -46,8 +46,8 @@ public class ChunkedWriterTest {
@Test
public void write_four_chunks() throws Exception {
final AtomicInteger numWrites = new AtomicInteger();
- try (final OutputStreamWriter osw = getOutputStreamWriter(numWrites)) {
- try (final ChunkedWriter chunked = new ChunkedWriter(osw, 10)) {
+ try (OutputStreamWriter osw = getOutputStreamWriter(numWrites)) {
+ try (ChunkedWriter chunked = new ChunkedWriter(osw, 10)) {
chunked.write("0123456789012345678901234567891".toCharArray());
chunked.flush();
assertEquals(4, numWrites.get());
@@ -58,8 +58,8 @@ public class ChunkedWriterTest {
@Test
public void write_two_chunks_default_constructor() throws Exception {
final AtomicInteger numWrites = new AtomicInteger();
- try (final OutputStreamWriter osw = getOutputStreamWriter(numWrites)) {
- try (final ChunkedWriter chunked = new ChunkedWriter(osw)) {
+ try (OutputStreamWriter osw = getOutputStreamWriter(numWrites)) {
+ try (ChunkedWriter chunked = new ChunkedWriter(osw)) {
chunked.write(new char[1024 * 4 + 1]);
chunked.flush();
assertEquals(2, numWrites.get());
diff --git a/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java
index 01b8a641..b265cfea 100644
--- a/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java
@@ -40,7 +40,7 @@ public class CountingOutputStreamTest {
@Test
public void testCounting() throws IOException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (final CountingOutputStream cos = new CountingOutputStream(baos)) {
+ try (CountingOutputStream cos = new CountingOutputStream(baos)) {
for (int i = 0; i < 20; i++) {
cos.write(i);
diff --git a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
index 9df2f8e4..0911e80a 100644
--- a/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
+++ b/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
@@ -122,63 +122,63 @@ public class FileWriterWithEncodingTest {
@Test
public void sameEncoding_Charset_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, Charset.defaultCharset())) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, Charset.defaultCharset())) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_CharsetEncoder_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, Charset.defaultCharset().newEncoder())) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, Charset.defaultCharset().newEncoder())) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_null_Charset_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, (Charset) null)) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, (Charset) null)) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_null_CharsetEncoder_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), (CharsetEncoder) null)) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), (CharsetEncoder) null)) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_null_CharsetName_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), (String) null)) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), (String) null)) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_string_Charset_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), Charset.defaultCharset())) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), Charset.defaultCharset())) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_string_CharsetEncoder_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), Charset.defaultCharset().newEncoder())) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), Charset.defaultCharset().newEncoder())) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_string_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, defaultEncoding)) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2, defaultEncoding)) {
successfulRun(writer);
}
}
@Test
public void sameEncoding_string_string_constructor() throws Exception {
- try (final FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), defaultEncoding)) {
+ try (FileWriterWithEncoding writer = new FileWriterWithEncoding(file2.getPath(), defaultEncoding)) {
successfulRun(writer);
}
}
diff --git a/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java
index 052c7b21..0991da0e 100644
--- a/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java
@@ -40,14 +40,14 @@ public class NullOutputStreamTest {
@Test
public void testNewInstance() throws IOException {
- try (final NullOutputStream nos = NullOutputStream.INSTANCE) {
+ try (NullOutputStream nos = NullOutputStream.INSTANCE) {
process(nos);
}
}
@Test
public void testSingleton() throws IOException {
- try (final NullOutputStream nos = NullOutputStream.INSTANCE) {
+ try (NullOutputStream nos = NullOutputStream.INSTANCE) {
process(nos);
}
}
diff --git a/src/test/java/org/apache/commons/io/output/NullPrintStreamTest.java b/src/test/java/org/apache/commons/io/output/NullPrintStreamTest.java
index 86a44395..80513feb 100644
--- a/src/test/java/org/apache/commons/io/output/NullPrintStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/NullPrintStreamTest.java
@@ -40,14 +40,14 @@ public class NullPrintStreamTest {
@Test
public void testNullNewInstance() throws IOException {
- try (final NullPrintStream nos = new NullPrintStream()) {
+ try (NullPrintStream nos = new NullPrintStream()) {
process(nos);
}
}
@Test
public void testNullSingleton() throws IOException {
- try (final NullPrintStream nos = NullPrintStream.INSTANCE) {
+ try (NullPrintStream nos = NullPrintStream.INSTANCE) {
process(nos);
}
}
diff --git a/src/test/java/org/apache/commons/io/output/NullWriterTest.java b/src/test/java/org/apache/commons/io/output/NullWriterTest.java
index b34fcc04..d6575469 100644
--- a/src/test/java/org/apache/commons/io/output/NullWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/NullWriterTest.java
@@ -27,7 +27,7 @@ public class NullWriterTest {
@Test
public void testNull() {
final char[] chars = { 'A', 'B', 'C' };
- try (final NullWriter writer = NullWriter.INSTANCE) {
+ try (NullWriter writer = NullWriter.INSTANCE) {
writer.write(1);
writer.write(chars);
writer.write(chars, 1, 1);
diff --git a/src/test/java/org/apache/commons/io/output/ProxyCollectionWriterTest.java b/src/test/java/org/apache/commons/io/output/ProxyCollectionWriterTest.java
index f87a1a5b..02e01b9e 100644
--- a/src/test/java/org/apache/commons/io/output/ProxyCollectionWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/ProxyCollectionWriterTest.java
@@ -394,12 +394,12 @@ public class ProxyCollectionWriterTest {
@Test
public void testConstructorsNull() throws IOException {
- try (final ProxyCollectionWriter teeWriter = new ProxyCollectionWriter((Writer[]) null)) {
+ try (ProxyCollectionWriter teeWriter = new ProxyCollectionWriter((Writer[]) null)) {
// Call any method, should not throw
teeWriter.append('a');
teeWriter.flush();
}
- try (final ProxyCollectionWriter teeWriter = new ProxyCollectionWriter((Collection<Writer>) null)) {
+ try (ProxyCollectionWriter teeWriter = new ProxyCollectionWriter((Collection<Writer>) null)) {
// Call any method, should not throw
teeWriter.append('a');
teeWriter.flush();
diff --git a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
index 90d96781..07a747c6 100644
--- a/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
@@ -34,7 +34,7 @@ public class ProxyWriterTest {
@Test
public void appendChar() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.append('c');
assertEquals("c", writer.toString());
@@ -43,7 +43,7 @@ public class ProxyWriterTest {
@Test
public void appendCharSequence() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.append("ABC");
assertEquals("ABC", writer.toString());
@@ -52,7 +52,7 @@ public class ProxyWriterTest {
@Test
public void appendCharSequence_with_offset() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.append("ABC", 1, 3);
proxy.flush();
@@ -62,7 +62,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_append_char() throws IOException {
- try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
final OutputStreamWriter osw = new OutputStreamWriter(baos) {
@Override
public void write(final int c) throws IOException {
@@ -77,7 +77,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_append_charSequence() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public Writer append(final CharSequence csq) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -91,7 +91,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_append_charSequence_offset() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public Writer append(final CharSequence csq, final int start, final int end) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -106,13 +106,13 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_close() {
assertThrows(UnsupportedEncodingException.class, () -> {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void close() throws IOException {
throw new UnsupportedEncodingException("Bah");
}
}) {
- try (final ProxyWriter proxy = new ProxyWriter(osw)) {
+ try (ProxyWriter proxy = new ProxyWriter(osw)) {
// noop
}
}
@@ -121,7 +121,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_flush() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void flush() throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -135,7 +135,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_write_char_array() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void write(final char[] cbuf) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -149,7 +149,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_write_int() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void write(final int c) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -163,7 +163,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_write_offset_char_array() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void write(final char[] cbuf, final int off, final int len) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -177,7 +177,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_write_string() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void write(final String str) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -191,7 +191,7 @@ public class ProxyWriterTest {
@Test
public void exceptions_in_write_string_offset() throws IOException {
- try (final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
+ try (OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) {
@Override
public void write(final String str, final int off, final int len) throws IOException {
throw new UnsupportedEncodingException("Bah");
@@ -205,7 +205,7 @@ public class ProxyWriterTest {
@Test
public void nullCharArray() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
+ try (ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.write((char[]) null);
proxy.write((char[]) null, 0, 0);
}
@@ -213,14 +213,14 @@ public class ProxyWriterTest {
@Test
public void nullCharSequence() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
+ try (ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.append(null);
}
}
@Test
public void nullString() throws Exception {
- try (final ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
+ try (ProxyWriter proxy = new ProxyWriter(NullWriter.INSTANCE)) {
proxy.write((String) null);
proxy.write((String) null, 0, 0);
}
@@ -228,7 +228,7 @@ public class ProxyWriterTest {
@Test
public void writeCharArray() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.write(new char[] { 'A', 'B', 'C' });
assertEquals("ABC", writer.toString());
@@ -237,7 +237,7 @@ public class ProxyWriterTest {
@Test
public void writeCharArrayPartial() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.write(new char[] { 'A', 'B', 'C' }, 1, 2);
assertEquals("BC", writer.toString());
@@ -246,7 +246,7 @@ public class ProxyWriterTest {
@Test
public void writeInt() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.write(65);
assertEquals("A", writer.toString());
@@ -255,7 +255,7 @@ public class ProxyWriterTest {
@Test
public void writeString() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.write("ABC");
assertEquals("ABC", writer.toString());
@@ -264,7 +264,7 @@ public class ProxyWriterTest {
@Test
public void writeStringPartial() throws Exception {
- try (final StringBuilderWriter writer = new StringBuilderWriter();
+ try (StringBuilderWriter writer = new StringBuilderWriter();
final ProxyWriter proxy = new ProxyWriter(writer)) {
proxy.write("ABC", 1, 2);
assertEquals("BC", writer.toString());
diff --git a/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
index c1aeaf81..8502e05b 100644
--- a/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/QueueOutputStreamTest.java
@@ -67,7 +67,7 @@ public class QueueOutputStreamTest {
@Test
public void writeInterrupted() throws Exception {
- try (final QueueOutputStream outputStream = new QueueOutputStream(new LinkedBlockingQueue<>(1));
+ try (QueueOutputStream outputStream = new QueueOutputStream(new LinkedBlockingQueue<>(1));
final QueueInputStream inputStream = outputStream.newQueueInputStream()) {
final int timeout = 1;
@@ -98,7 +98,7 @@ public class QueueOutputStreamTest {
@Test
public void writeString() throws Exception {
- try (final QueueOutputStream outputStream = new QueueOutputStream();
+ try (QueueOutputStream outputStream = new QueueOutputStream();
final QueueInputStream inputStream = outputStream.newQueueInputStream()) {
outputStream.write("ABC".getBytes(UTF_8));
final String value = IOUtils.toString(inputStream, UTF_8);
@@ -108,7 +108,7 @@ public class QueueOutputStreamTest {
@Test
public void writeStringMultiThread() throws Exception {
- try (final QueueOutputStream outputStream = callInThrowAwayThread(QueueOutputStream::new);
+ try (QueueOutputStream outputStream = callInThrowAwayThread(QueueOutputStream::new);
final QueueInputStream inputStream = callInThrowAwayThread(outputStream::newQueueInputStream)) {
callInThrowAwayThread(() -> {
outputStream.write("ABC".getBytes(UTF_8));
diff --git a/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java b/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
index 583629d7..a268585e 100644
--- a/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java
@@ -33,7 +33,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendChar() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.append('F').append('o').append('o');
assertEquals("Foo", writer.toString());
}
@@ -41,7 +41,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendCharSequence() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.append("Foo").append("Bar");
assertEquals("FooBar", writer.toString());
}
@@ -49,7 +49,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendCharSequencePortion() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.append("FooBar", 3, 6).append(new StringBuffer("FooBar"), 0, 3);
assertEquals("BarFoo", writer.toString());
}
@@ -57,7 +57,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendConstructCapacity() throws IOException {
- try (final Writer writer = new StringBuilderWriter(100)) {
+ try (Writer writer = new StringBuilderWriter(100)) {
writer.append("Foo");
assertEquals("Foo", writer.toString());
}
@@ -65,7 +65,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendConstructNull() throws IOException {
- try (final Writer writer = new StringBuilderWriter(null)) {
+ try (Writer writer = new StringBuilderWriter(null)) {
writer.append("Foo");
assertEquals("Foo", writer.toString());
}
@@ -74,7 +74,7 @@ public class StringBuilderWriterTest {
@Test
public void testAppendConstructStringBuilder() {
final StringBuilder builder = new StringBuilder("Foo");
- try (final StringBuilderWriter writer = new StringBuilderWriter(builder)) {
+ try (StringBuilderWriter writer = new StringBuilderWriter(builder)) {
writer.append("Bar");
assertEquals("FooBar", writer.toString());
assertSame(builder, writer.getBuilder());
@@ -83,7 +83,7 @@ public class StringBuilderWriterTest {
@Test
public void testClose() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.append("Foo");
writer.close();
writer.append("Bar");
@@ -93,7 +93,7 @@ public class StringBuilderWriterTest {
@Test
public void testWriteChar() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.write('F');
assertEquals("F", writer.toString());
writer.write('o');
@@ -105,7 +105,7 @@ public class StringBuilderWriterTest {
@Test
public void testWriteCharArray() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.write(new char[] { 'F', 'o', 'o' });
assertEquals("Foo", writer.toString());
writer.write(new char[] { 'B', 'a', 'r' });
@@ -115,7 +115,7 @@ public class StringBuilderWriterTest {
@Test
public void testWriteCharArrayPortion() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.write(FOOBAR_CHARS, 3, 3);
assertEquals("Bar", writer.toString());
writer.write(FOOBAR_CHARS, 0, 3);
@@ -125,7 +125,7 @@ public class StringBuilderWriterTest {
@Test
public void testWriteString() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.write("Foo");
assertEquals("Foo", writer.toString());
writer.write("Bar");
@@ -135,7 +135,7 @@ public class StringBuilderWriterTest {
@Test
public void testWriteStringPortion() throws IOException {
- try (final Writer writer = new StringBuilderWriter()) {
+ try (Writer writer = new StringBuilderWriter()) {
writer.write("FooBar", 3, 3);
assertEquals("Bar", writer.toString());
writer.write("FooBar", 0, 3);
diff --git a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
index 0c24d99f..e9a56903 100644
--- a/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java
@@ -83,8 +83,8 @@ public class TaggedOutputStreamTest {
@Test
public void testNormalStream() {
- try (final ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
- try (final OutputStream stream = new TaggedOutputStream(buffer)) {
+ try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
+ try (OutputStream stream = new TaggedOutputStream(buffer)) {
stream.write('a');
stream.write(new byte[] { 'b' });
stream.write(new byte[] { 'c' }, 0, 1);
@@ -102,7 +102,7 @@ public class TaggedOutputStreamTest {
@Test
public void testOtherException() throws Exception {
final IOException exception = new IOException("test exception");
- try (final TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.INSTANCE)) {
+ try (TaggedOutputStream stream = new TaggedOutputStream(ClosedOutputStream.INSTANCE)) {
assertFalse(stream.isCauseOf(exception));
assertFalse(stream.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));
diff --git a/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java b/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
index 6f86bbfe..7423c953 100644
--- a/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/TaggedWriterTest.java
@@ -83,8 +83,8 @@ public class TaggedWriterTest {
@Test
public void testNormalWriter() throws IOException {
- try (final StringBuilderWriter buffer = new StringBuilderWriter()) {
- try (final Writer writer = new TaggedWriter(buffer)) {
+ try (StringBuilderWriter buffer = new StringBuilderWriter()) {
+ try (Writer writer = new TaggedWriter(buffer)) {
writer.write('a');
writer.write(new char[] { 'b' });
writer.write(new char[] { 'c' }, 0, 1);
@@ -100,7 +100,7 @@ public class TaggedWriterTest {
@Test
public void testOtherException() throws Exception {
final IOException exception = new IOException("test exception");
- try (final TaggedWriter writer = new TaggedWriter(ClosedWriter.INSTANCE)) {
+ try (TaggedWriter writer = new TaggedWriter(ClosedWriter.INSTANCE)) {
assertFalse(writer.isCauseOf(exception));
assertFalse(writer.isCauseOf(new TaggedIOException(exception, UUID.randomUUID())));
writer.throwIfCauseOf(exception);
diff --git a/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java
index c75a42fb..a417a00f 100644
--- a/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java
@@ -80,7 +80,7 @@ public class TeeOutputStreamTest {
final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
final ByteArrayOutputStream expected = new ByteArrayOutputStream();
- try (final TeeOutputStream tos = new TeeOutputStream(baos1, baos2)) {
+ try (TeeOutputStream tos = new TeeOutputStream(baos1, baos2)) {
for (int i = 0; i < 20; i++) {
tos.write(i);
expected.write(i);
diff --git a/src/test/java/org/apache/commons/io/output/TeeWriterTest.java b/src/test/java/org/apache/commons/io/output/TeeWriterTest.java
index 10a13a15..c3e3a800 100644
--- a/src/test/java/org/apache/commons/io/output/TeeWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/TeeWriterTest.java
@@ -374,12 +374,12 @@ public class TeeWriterTest {
@Test
public void testConstructorsNull() throws IOException {
- try (final TeeWriter teeWriter = new TeeWriter((Writer[]) null)) {
+ try (TeeWriter teeWriter = new TeeWriter((Writer[]) null)) {
// Call any method, should not throw
teeWriter.append('a');
teeWriter.flush();
}
- try (final TeeWriter teeWriter = new TeeWriter((Collection<Writer>) null)) {
+ try (TeeWriter teeWriter = new TeeWriter((Collection<Writer>) null)) {
// Call any method, should not throw
teeWriter.append('a');
teeWriter.flush();
@@ -393,7 +393,7 @@ public class TeeWriterTest {
final StringBuilderWriter sbw2 = new StringBuilderWriter();
final StringBuilderWriter expected = new StringBuilderWriter();
- try (final TeeWriter tw = new TeeWriter(sbw1, sbw2, null)) {
+ try (TeeWriter tw = new TeeWriter(sbw1, sbw2, null)) {
for (int i = 0; i < 20; i++) {
tw.write(i);
expected.write(i);
diff --git a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
index 1bcfc121..8d278df4 100644
--- a/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java
@@ -32,7 +32,7 @@ public class ThresholdingOutputStreamTest {
@Test
public void testSetByteCount() throws Exception {
final AtomicBoolean reached = new AtomicBoolean(false);
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(3) {
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(3) {
{
setByteCount(2);
}
@@ -59,7 +59,7 @@ public class ThresholdingOutputStreamTest {
final AtomicBoolean reached = new AtomicBoolean();
// Null threshold consumer
reached.set(false);
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(1, null,
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(1, null,
os -> new ByteArrayOutputStream(4))) {
tos.write('a');
assertFalse(reached.get());
@@ -68,7 +68,7 @@ public class ThresholdingOutputStreamTest {
}
// Null output stream function
reached.set(false);
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> reached.set(true), null)) {
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> reached.set(true), null)) {
tos.write('a');
assertFalse(reached.get());
tos.write('a');
@@ -76,7 +76,7 @@ public class ThresholdingOutputStreamTest {
}
// non-null inputs.
reached.set(false);
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> reached.set(true),
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> reached.set(true),
os -> new ByteArrayOutputStream(4))) {
tos.write('a');
assertFalse(reached.get());
@@ -87,7 +87,7 @@ public class ThresholdingOutputStreamTest {
@Test
public void testThresholdIOConsumerIOException() throws Exception {
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> {
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> {
throw new IOException("Threshold reached.");
}, os -> new ByteArrayOutputStream(4))) {
tos.write('a');
@@ -97,7 +97,7 @@ public class ThresholdingOutputStreamTest {
@Test
public void testThresholdIOConsumerUncheckedException() throws Exception {
- try (final ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> {
+ try (ThresholdingOutputStream tos = new ThresholdingOutputStream(1, os -> {
throw new IllegalStateException("Threshold reached.");
}, os -> new ByteArrayOutputStream(4))) {
tos.write('a');
diff --git a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
index 50c840d5..3401d69d 100644
--- a/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java
@@ -47,7 +47,7 @@ public class WriterOutputStreamTest {
@Test
public void testFlush() throws IOException {
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, false)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, false)) {
out.write("abc".getBytes(StandardCharsets.US_ASCII));
assertEquals(0, writer.getBuffer().length());
out.flush();
@@ -145,7 +145,7 @@ public class WriterOutputStreamTest {
private void testWithBufferedWrite(final String testString, final String charsetName) throws IOException {
final byte[] expected = testString.getBytes(charsetName);
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, charsetName)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, charsetName)) {
int offset = 0;
while (offset < expected.length) {
final int length = Math.min(random.nextInt(128), expected.length - offset);
@@ -160,7 +160,7 @@ public class WriterOutputStreamTest {
private void testWithSingleByteWrite(final String testString, final Charset charset) throws IOException {
final byte[] bytes = testString.getBytes(Charsets.toCharset(charset));
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, charset)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, charset)) {
for (final byte b : bytes) {
out.write(b);
}
@@ -171,7 +171,7 @@ public class WriterOutputStreamTest {
private void testWithSingleByteWrite(final String testString, final CharsetDecoder charsetDecoder) throws IOException {
final byte[] bytes = testString.getBytes(CharsetDecoders.toCharsetDecoder(charsetDecoder).charset());
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, charsetDecoder)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, charsetDecoder)) {
for (final byte b : bytes) {
out.write(b);
}
@@ -182,7 +182,7 @@ public class WriterOutputStreamTest {
private void testWithSingleByteWrite(final String testString, final String charsetName) throws IOException {
final byte[] bytes = testString.getBytes(Charsets.toCharset(charsetName));
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, charsetName)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, charsetName)) {
for (final byte b : bytes) {
out.write(b);
}
@@ -193,7 +193,7 @@ public class WriterOutputStreamTest {
@Test
public void testWriteImmediately() throws IOException {
final StringWriter writer = new StringWriter();
- try (final WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, true)) {
+ try (WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, true)) {
out.write("abc".getBytes(StandardCharsets.US_ASCII));
assertEquals("abc", writer.toString());
}
diff --git a/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java b/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
index ac06bf11..3526b516 100644
--- a/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
+++ b/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java
@@ -92,7 +92,7 @@ public class XmlStreamWriterTest {
@Test
public void testEmpty() throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
- try (final XmlStreamWriter writer = new XmlStreamWriter(out)) {
+ try (XmlStreamWriter writer = new XmlStreamWriter(out)) {
writer.flush();
writer.write("");
writer.flush();
diff --git a/src/test/java/org/apache/commons/io/test/TestUtils.java b/src/test/java/org/apache/commons/io/test/TestUtils.java
index ca9ab348..d6e12efa 100644
--- a/src/test/java/org/apache/commons/io/test/TestUtils.java
+++ b/src/test/java/org/apache/commons/io/test/TestUtils.java
@@ -170,7 +170,7 @@ public abstract class TestUtils {
throw new IOException("Cannot create file " + file
+ " as the parent directory does not exist");
}
- try (final BufferedOutputStream output =
+ try (BufferedOutputStream output =
new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
generateTestData(output, size);
}
@@ -180,7 +180,7 @@ public abstract class TestUtils {
if (file.getParentFile() != null && !file.getParentFile().exists()) {
throw new IOException("Cannot create file " + file + " as the parent directory does not exist");
}
- try (final PrintWriter output = new PrintWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8))) {
+ try (PrintWriter output = new PrintWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8))) {
for (final String element : data) {
output.println(element);
}
@@ -194,14 +194,14 @@ public abstract class TestUtils {
}
public static void generateTestData(final File file, final long size) throws IOException, FileNotFoundException {
- try (final BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
generateTestData(output, size);
}
}
public static byte[] generateTestData(final long size) {
try {
- try (final ByteArrayOutputStream baout = new ByteArrayOutputStream()) {
+ try (ByteArrayOutputStream baout = new ByteArrayOutputStream()) {
generateTestData(baout, size);
return baout.toByteArray();
}