public static char[] readIn(InputStream inStream, String encoding) throws IOException { try { byte[] buf = new byte[10]; StringAppender sb = new StringAppender(10, encoding); int bytesRead; while ((bytesRead = inStream.read(buf)) > 0) { for (int i = 0; i < bytesRead; i++) { sb.append(buf[i]); } } //noinspection unchecked return sb.toChars(); } finally { if (inStream != null) inStream.close(); } }
public static char[] readIn(InputStream inStream, String encoding) throws IOException { try { byte[] buf = new byte[10]; StringAppender sb = new StringAppender(10, encoding); int bytesRead; while ((bytesRead = inStream.read(buf)) > 0) { for (int i = 0; i < bytesRead; i++) { sb.append(buf[i]); } } //noinspection unchecked return sb.toChars(); } finally { if (inStream != null) inStream.close(); } }
public static char[] loadFromFile(File file, String encoding) throws IOException { if (!file.exists()) throw new RuntimeException("cannot find file: " + file.getName()); FileInputStream inStream = null; ReadableByteChannel fc = null; try { fc = (inStream = new FileInputStream(file)).getChannel(); ByteBuffer buf = allocateDirect(10); StringAppender sb = new StringAppender((int) file.length(), encoding); int read = 0; while (read >= 0) { buf.rewind(); read = fc.read(buf); buf.rewind(); for (; read > 0; read--) { sb.append(buf.get()); } } //noinspection unchecked return sb.toChars(); } catch (FileNotFoundException e) { // this can't be thrown, we check for this explicitly. } finally { if (inStream != null) inStream.close(); if (fc != null) fc.close(); } return null; }
public static char[] readIn(InputStream inStream, String encoding) throws IOException { try { byte[] buf = new byte[10]; StringAppender sb = new StringAppender(10, encoding); int bytesRead; while ((bytesRead = inStream.read(buf)) > 0) { for (int i = 0; i < bytesRead; i++) { sb.append(buf[i]); } } //noinspection unchecked return sb.toChars(); } finally { if (inStream != null) inStream.close(); } }
public static char[] loadFromFile(File file, String encoding) throws IOException { if (!file.exists()) throw new RuntimeException("cannot find file: " + file.getName()); FileInputStream inStream = null; ReadableByteChannel fc = null; try { fc = (inStream = new FileInputStream(file)).getChannel(); ByteBuffer buf = allocateDirect(10); StringAppender sb = new StringAppender((int) file.length(), encoding); int read = 0; while (read >= 0) { buf.rewind(); read = fc.read(buf); buf.rewind(); for (; read > 0; read--) { sb.append(buf.get()); } } //noinspection unchecked return sb.toChars(); } catch (FileNotFoundException e) { // this can't be thrown, we check for this explicitly. } finally { if (inStream != null) inStream.close(); if (fc != null) fc.close(); } return null; }
public static char[] loadFromFile(File file, String encoding) throws IOException { if (!file.exists()) throw new CompileException("cannot find file: " + file.getName()); FileInputStream inStream = null; ReadableByteChannel fc = null; try { fc = (inStream = new FileInputStream(file)).getChannel(); ByteBuffer buf = allocateDirect(10); StringAppender sb = new StringAppender((int) file.length(), encoding); int read = 0; while (read >= 0) { buf.rewind(); read = fc.read(buf); buf.rewind(); for (; read > 0; read--) { sb.append(buf.get()); } } //noinspection unchecked return sb.toChars(); } catch (FileNotFoundException e) { // this can't be thrown, we check for this explicitly. } finally { if (inStream != null) inStream.close(); if (fc != null) fc.close(); } return null; }
return appender.toChars();
return appender.toChars();
subCompileExpression( new StringAppender(nestParm).append('.') .append(subset(block, start, end - start)).toChars(), pCtx), egressType, pCtx) ); new ParmValuePair(null, (ExecutableStatement) subCompileExpression(new StringAppender(nestParm).append('.') .append(subset(block, start, end - start)).toChars(), pCtx), egressType, pCtx) );