Marginally cleaner isVCFStream() function
-- cleanup trying to debug minor bug. Failed to fix the bug, but the code is nicer now
This commit is contained in:
parent
74f9ccf6dd
commit
9f6f0c443c
|
|
@ -601,12 +601,15 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec,
|
||||||
private final static boolean isVCFStream(final InputStream stream, final String MAGIC_HEADER_LINE) {
|
private final static boolean isVCFStream(final InputStream stream, final String MAGIC_HEADER_LINE) {
|
||||||
try {
|
try {
|
||||||
byte[] buff = new byte[MAGIC_HEADER_LINE.length()];
|
byte[] buff = new byte[MAGIC_HEADER_LINE.length()];
|
||||||
stream.read(buff, 0, MAGIC_HEADER_LINE.length());
|
int nread = stream.read(buff, 0, MAGIC_HEADER_LINE.length());
|
||||||
String firstLine = new String(buff);
|
boolean eq = Arrays.equals(buff, MAGIC_HEADER_LINE.getBytes());
|
||||||
stream.close();
|
return eq;
|
||||||
return firstLine.startsWith(MAGIC_HEADER_LINE);
|
// String firstLine = new String(buff);
|
||||||
|
// return firstLine.startsWith(MAGIC_HEADER_LINE);
|
||||||
} catch ( IOException e ) {
|
} catch ( IOException e ) {
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
try { stream.close(); } catch ( IOException e ) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue