Skip to content

Commit d269f16

Browse files
committed
Minor refactorings.
1 parent 835a8d4 commit d269f16

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

src/main/java/org/apache/commons/io/input/UncheckedBufferedReader.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void close() throws UncheckedIOException {
7373
try {
7474
super.close();
7575
} catch (final IOException e) {
76-
throw new UncheckedIOException(e);
76+
throw uncheck(e);
7777
}
7878
}
7979

@@ -85,7 +85,7 @@ public void mark(final int readAheadLimit) throws UncheckedIOException {
8585
try {
8686
super.mark(readAheadLimit);
8787
} catch (final IOException e) {
88-
throw new UncheckedIOException(e);
88+
throw uncheck(e);
8989
}
9090
}
9191

@@ -97,7 +97,7 @@ public int read() throws UncheckedIOException {
9797
try {
9898
return super.read();
9999
} catch (final IOException e) {
100-
throw new UncheckedIOException(e);
100+
throw uncheck(e);
101101
}
102102
}
103103

@@ -109,7 +109,7 @@ public int read(final char[] cbuf) throws UncheckedIOException {
109109
try {
110110
return super.read(cbuf);
111111
} catch (final IOException e) {
112-
throw new UncheckedIOException(e);
112+
throw uncheck(e);
113113
}
114114
}
115115

@@ -121,7 +121,7 @@ public int read(final char[] cbuf, final int off, final int len) throws Unchecke
121121
try {
122122
return super.read(cbuf, off, len);
123123
} catch (final IOException e) {
124-
throw new UncheckedIOException(e);
124+
throw uncheck(e);
125125
}
126126
}
127127

@@ -133,7 +133,7 @@ public int read(final CharBuffer target) throws UncheckedIOException {
133133
try {
134134
return super.read(target);
135135
} catch (final IOException e) {
136-
throw new UncheckedIOException(e);
136+
throw uncheck(e);
137137
}
138138
}
139139

@@ -145,7 +145,7 @@ public String readLine() throws UncheckedIOException {
145145
try {
146146
return super.readLine();
147147
} catch (final IOException e) {
148-
throw new UncheckedIOException(e);
148+
throw uncheck(e);
149149
}
150150
}
151151

@@ -157,7 +157,7 @@ public boolean ready() throws UncheckedIOException {
157157
try {
158158
return super.ready();
159159
} catch (final IOException e) {
160-
throw new UncheckedIOException(e);
160+
throw uncheck(e);
161161
}
162162
}
163163

@@ -169,7 +169,7 @@ public void reset() throws UncheckedIOException {
169169
try {
170170
super.reset();
171171
} catch (final IOException e) {
172-
throw new UncheckedIOException(e);
172+
throw uncheck(e);
173173
}
174174
}
175175

@@ -181,8 +181,12 @@ public long skip(final long n) throws UncheckedIOException {
181181
try {
182182
return super.skip(n);
183183
} catch (final IOException e) {
184-
throw new UncheckedIOException(e);
184+
throw uncheck(e);
185185
}
186186
}
187187

188+
private UncheckedIOException uncheck(final IOException e) {
189+
return new UncheckedIOException(e);
190+
}
191+
188192
}

src/main/java/org/apache/commons/io/input/UncheckedFilterReader.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void close() throws UncheckedIOException {
6262
try {
6363
super.close();
6464
} catch (final IOException e) {
65-
throw new UncheckedIOException(e);
65+
throw uncheck(e);
6666
}
6767
}
6868

@@ -74,7 +74,7 @@ public void mark(final int readAheadLimit) throws UncheckedIOException {
7474
try {
7575
super.mark(readAheadLimit);
7676
} catch (final IOException e) {
77-
throw new UncheckedIOException(e);
77+
throw uncheck(e);
7878
}
7979
}
8080

@@ -86,7 +86,7 @@ public int read() throws UncheckedIOException {
8686
try {
8787
return super.read();
8888
} catch (final IOException e) {
89-
throw new UncheckedIOException(e);
89+
throw uncheck(e);
9090
}
9191
}
9292

@@ -98,7 +98,7 @@ public int read(final char[] cbuf) throws UncheckedIOException {
9898
try {
9999
return super.read(cbuf);
100100
} catch (final IOException e) {
101-
throw new UncheckedIOException(e);
101+
throw uncheck(e);
102102
}
103103
}
104104

@@ -110,7 +110,7 @@ public int read(final char[] cbuf, final int off, final int len) throws Unchecke
110110
try {
111111
return super.read(cbuf, off, len);
112112
} catch (final IOException e) {
113-
throw new UncheckedIOException(e);
113+
throw uncheck(e);
114114
}
115115
}
116116

@@ -122,7 +122,7 @@ public int read(final CharBuffer target) throws UncheckedIOException {
122122
try {
123123
return super.read(target);
124124
} catch (final IOException e) {
125-
throw new UncheckedIOException(e);
125+
throw uncheck(e);
126126
}
127127
}
128128

@@ -134,7 +134,7 @@ public boolean ready() throws UncheckedIOException {
134134
try {
135135
return super.ready();
136136
} catch (final IOException e) {
137-
throw new UncheckedIOException(e);
137+
throw uncheck(e);
138138
}
139139
}
140140

@@ -146,7 +146,7 @@ public void reset() throws UncheckedIOException {
146146
try {
147147
super.reset();
148148
} catch (final IOException e) {
149-
throw new UncheckedIOException(e);
149+
throw uncheck(e);
150150
}
151151
}
152152

@@ -158,8 +158,12 @@ public long skip(final long n) throws UncheckedIOException {
158158
try {
159159
return super.skip(n);
160160
} catch (final IOException e) {
161-
throw new UncheckedIOException(e);
161+
throw uncheck(e);
162162
}
163163
}
164164

165+
private UncheckedIOException uncheck(final IOException e) {
166+
return new UncheckedIOException(e);
167+
}
168+
165169
}

0 commit comments

Comments
 (0)