/** Reads in a string until NULL or EOF encountered. */ private StringValue readOriginalString() throws IOException { StringValue sb = _env.createUnicodeBuilder(); for (int ch = _in.read(); ch > 0; ch = _in.read()) { sb.append((char) ch); } return sb; }
/** Executes the JSP Page */ public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; _caucho_init(req, res); if (_hasSession) { req.getSession(); res.setHeader("Cache-Control", "private"); } // res.setContentLength(_contentLength); TempCharBuffer buf = TempCharBuffer.allocate(); char[] cBuf = buf.getBuffer(); int len; PrintWriter out = response.getWriter(); ReadStream rs = _cacheEntry.openRead(); rs.setEncoding("UTF-8"); try { while ((len = rs.read(cBuf, 0, cBuf.length)) > 0) { out.write(cBuf, 0, len); } } finally { rs.close(); } TempCharBuffer.free(buf); }
private static String parseName(ReadStream is) throws IOException { int ch; for (ch = is.read(); ch > 0 && ch != '"'; ch = is.read()) {} if (ch < 0) return null; CharBuffer cb = new CharBuffer(); for (ch = is.read(); ch > 0 && ch != '"'; ch = is.read()) { cb.append((char) ch); } if (ch < 0) return null; return cb.toString(); }
private int readInt() throws IOException { int len = _in.read(_tmpBuf); if (len != 4) return -1; if (_isLittleEndian) { return (_tmpBuf[0] & 0xff) | (_tmpBuf[1] & 0xff) << 8 | (_tmpBuf[2] & 0xff) << 16 | _tmpBuf[3] << 24; } else { return _tmpBuf[0] << 24 | (_tmpBuf[1] & 0xff) << 16 | (_tmpBuf[2] & 0xff) << 8 | (_tmpBuf[3] & 0xff); } }
/** Reads a character from a file, returning -1 on EOF. */ public int read() throws IOException { try { if (_is != null) { int c = _is.read(); if (c < 0) _isEOF = true; return c; } else return -1; } catch (IOException e) { _isTimeout = true; _isEOF = true; log.log(Level.FINER, e.toString(), e); return -1; } }
/** Reads a buffer from a file, returning -1 on EOF. */ public int read(char[] buffer, int offset, int length) throws IOException { try { if (_is != null) { int c = _is.read(buffer, offset, length); if (c == -1) _isEOF = true; else _isEOF = false; return c; } else return -1; } catch (IOException e) { _isTimeout = true; _isEOF = true; log.log(Level.FINER, e.toString(), e); return -1; } }