CharsetDetector { public Reader getReader(InputStream in, String declaredEncoding) { fDeclaredEncoding = declaredEncoding; try { setText(in); CharsetMatch match = detect(); if (match == null) { return null; } return match.getReader(); } catch (IOException e) { return null; } } CharsetDetector();  CharsetDetector(int markLimit); static String[] getAllDetectableCharsets(); CharsetDetector setDeclaredEncoding(String encoding); CharsetDetector setText(byte[] in); CharsetDetector setText(InputStream in); CharsetMatch detect(); CharsetMatch[] detectAll(); Reader getReader(InputStream in, String declaredEncoding); String getString(byte[] in, String declaredEncoding); boolean inputFilterEnabled(); boolean enableInputFilter(boolean filter); @Deprecated String[] getDetectableCharsets(); @Deprecated CharsetDetector setDetectableCharset(String encoding, boolean enabled);  }
@Test public void testEmptyOrNullDeclaredCharset() throws IOException { try (InputStream in = getResourceAsStream("/test-documents/resume.html")) { CharsetDetector detector = new CharsetDetector(); Reader reader = detector.getReader(in, null); assertTrue(reader.ready()); reader = detector.getReader(in, ""); assertTrue(reader.ready()); } }