@Override public FileDescriptor getFileDescriptor() throws IOException { if (in instanceof HasFileDescriptor) { return ((HasFileDescriptor) in).getFileDescriptor(); } else if (in instanceof FileInputStream) { return ((FileInputStream) in).getFD(); } else { return null; } }
private static FileDescriptor getFileDescriptorIfAvail(InputStream in) { FileDescriptor fd = null; try { if (in instanceof HasFileDescriptor) { fd = ((HasFileDescriptor)in).getFileDescriptor(); } else if (in instanceof FileInputStream) { fd = ((FileInputStream)in).getFD(); } } catch (IOException e) { LOG.info("Unable to determine FileDescriptor", e); } return fd; }