@@ -187,6 +187,7 @@ public static String[] getAllDetectableCharsets() {
187187 * analyzed will not be added to the list of possible encodings.
188188 *
189189 * @param encoding The declared encoding
190+ * @return This CharsetDetector
190191 * @stable ICU 3.4
191192 */
192193 public CharsetDetector setDeclaredEncoding (String encoding ) {
@@ -225,6 +226,7 @@ private CharsetDetector setText(byte[] in, int length) {
225226 *
226227 * @param in the input text of unknown encoding
227228 * @return This CharsetDetector
229+ * @throws java.io.IOException if there is an error while reading.
228230 * @stable ICU 3.4
229231 */
230232
@@ -260,12 +262,6 @@ public CharsetDetector setText(InputStream in) throws IOException {
260262 * only looks at the start of the input data,
261263 * there is a possibility that the returned charset will fail to handle
262264 * the full set of input data.
263- * <p>
264- * Raise an exception if
265- * <ul>
266- * <li>no charset appears to match the data.</li>
267- * <li>no input text has been provided</li>
268- * </ul>
269265 *
270266 * @return a CharsetMatch object representing the best matching charset, or
271267 * <code>null</code> if there are no matches.
@@ -289,12 +285,6 @@ public CharsetMatch detect() {
289285 * Return an array of all charsets that appear to be plausible
290286 * matches with the input data. The array is ordered with the
291287 * best quality match first.
292- * <p>
293- * Raise an exception if
294- * <ul>
295- * <li>no charsets appear to match the input data.</li>
296- * <li>no input text has been provided</li>
297- * </ul>
298288 *
299289 * @return An array of CharsetMatch objects representing possibly matching charsets.
300290 * @stable ICU 3.4
@@ -330,7 +320,7 @@ public CharsetMatch[] detectAll() {
330320 }
331321 Collections .sort (matches ); // CharsetMatch compares on confidence
332322 Collections .reverse (matches ); // Put best match first.
333- return matches .toArray (new CharsetMatch [0 ] );
323+ return matches .toArray (CharsetMatch []:: new );
334324 }
335325
336326 /**
@@ -345,12 +335,14 @@ public CharsetMatch[] detectAll() {
345335 * then return the stream to its original position via
346336 * the InputStream.reset() operation. The exact amount that will
347337 * be read depends on the characteristics of the data itself.
348- * <p>
349- * Raise an exception if no charsets appear to match the input data.
350338 *
351339 * @param in The source of the byte data in the unknown charset.
352340 * @param declaredEncoding A declared encoding for the data, if available,
353341 * or null or an empty string if none is available.
342+ *
343+ * @return an appropriate Java Reader or null if no charsets appear to match the input data or
344+ * if an error occurred.
345+ *
354346 * @stable ICU 3.4
355347 */
356348 public Reader getReader (InputStream in , String declaredEncoding ) {
@@ -378,12 +370,14 @@ public Reader getReader(InputStream in, String declaredEncoding) {
378370 * <p>
379371 * This is a convenience method that is equivalent to
380372 * <code>this.setDeclaredEncoding(declaredEncoding).setText(in).detect().getString();</code>
381- * <p>
382- * Raise an exception if no charsets appear to match the input data.
383373 *
384374 * @param in The source of the byte data in the unknown charset.
385375 * @param declaredEncoding A declared encoding for the data, if available,
386376 * or null or an empty string if none is available.
377+ *
378+ * @return a String containing the converted input data, or null if no charsets appear to match
379+ * the input data or if an error occurred.
380+ *
387381 * @stable ICU 3.4
388382 */
389383 public String getString (byte [] in , String declaredEncoding ) {
@@ -547,7 +541,7 @@ public String[] getDetectableCharsets() {
547541 csnames .add (rcinfo .recognizer .getName ());
548542 }
549543 }
550- return csnames .toArray (new String [0 ] );
544+ return csnames .toArray (String []:: new );
551545 }
552546
553547 /**
0 commit comments