Java tutorial
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.Reader; public class Main { public static final int readerTryRead(Reader reader, char[] cc, int len) throws IOException { int r; int t = 0; while ((r = reader.read(cc, t, len - t)) >= 0) { t += r; if (t == len) { break; } } return t; } public static int readerTryRead(Reader reader, char[] cc) throws IOException { if (reader == null || cc == null || cc.length == 0) { return 0; } return readerTryRead(reader, cc, cc.length); } }