Skip to content

Commit 8cdf22e

Browse files
committed
Refactor magic number into constant.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1586307 13f79535-47bb-0310-9956-ffa450edef68
1 parent c4a7e64 commit 8cdf22e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
* @since 2.0
8686
*/
8787
public class BOMInputStream extends ProxyInputStream {
88+
private static final int EOF = -1;
8889
private final boolean include;
8990
/**
9091
* BOMs are sorted from longest to shortest.
@@ -140,7 +141,7 @@ public int compare(final ByteOrderMark bom1, final ByteOrderMark bom2) {
140141
final int len1 = bom1.length();
141142
final int len2 = bom2.length();
142143
if (len1 > len2) {
143-
return -1;
144+
return EOF;
144145
}
145146
if (len2 > len1) {
146147
return 1;
@@ -260,7 +261,7 @@ public String getBOMCharsetName() throws IOException {
260261
*/
261262
private int readFirstBytes() throws IOException {
262263
getBOM();
263-
return fbIndex < fbLength ? firstBytes[fbIndex++] : -1;
264+
return fbIndex < fbLength ? firstBytes[fbIndex++] : EOF;
264265
}
265266

266267
/**
@@ -340,7 +341,7 @@ public int read(final byte[] buf, int off, int len) throws IOException {
340341
}
341342
}
342343
final int secondCount = in.read(buf, off, len);
343-
return secondCount < 0 ? firstCount > 0 ? firstCount : -1 : firstCount + secondCount;
344+
return secondCount < 0 ? firstCount > 0 ? firstCount : EOF : firstCount + secondCount;
344345
}
345346

346347
/**

0 commit comments

Comments
 (0)