解决方法:InputStream iis = new InputStream() { private byte[] bits = "SegmentFault".getBytes(); private int index = 0; @Override public int read() throws IOException { int clone = index++; if (index > bits.length) { index = 0; return '\n'; } else { return bits[clone]; } } }; System.setIn(iis);
解决方法: