Package java.io

Examples of java.io.InputStream.available()


        String path = TestBundleActivator.class.getName().replace('.', '/') + ".class";
        os.putNextEntry(new ZipEntry(path));

        InputStream is = TestBundleActivator.class.getClassLoader().getResourceAsStream(path);
        byte[] b = new byte[is.available()];
        is.read(b);
        is.close();
        os.write(b);

        os.close();
View Full Code Here


      if(response==null) {
        synchronized(contentCache) {
          response = contentCache.get(resourcePath);
          if(response==null) {
            is = classLoader.getResourceAsStream(b.toString());
            if(is.available()==0) {
                    sendError(ctx, NOT_FOUND);
                    return null;       
            }
            baos = new ByteArrayOutputStream(is.available());
            int bt = -1;
View Full Code Here

            is = classLoader.getResourceAsStream(b.toString());
            if(is.available()==0) {
                    sendError(ctx, NOT_FOUND);
                    return null;       
            }
            baos = new ByteArrayOutputStream(is.available());
            int bt = -1;
            while((bt=is.read())!=-1) {
              baos.write(bt);
            }
            byte[] content = baos.toByteArray();
View Full Code Here

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    PrintWriter writer = resp.getWriter();
    InputStream is = VoteChartServlet.class.getClassLoader().getResourceAsStream("/index.html");
      while (is.available() > 0) {
          writer.write(is.read());
      }
      is.close();
  }
View Full Code Here

        InputStreamEntity entity;
        if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            InputStream stream = GZIPHelper.compressGzip(contentEncoding, in);
            entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                ? stream.available() != 0 ? stream.available() : -1 : -1);
        } else {
            entity = new InputStreamEntity(in, -1);
        }
        if (exchange != null) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
View Full Code Here

        InputStreamEntity entity;
        if (!exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            InputStream stream = GZIPHelper.compressGzip(contentEncoding, in);
            entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                ? stream.available() != 0 ? stream.available() : -1 : -1);
        } else {
            entity = new InputStreamEntity(in, -1);
        }
        if (exchange != null) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
View Full Code Here

        AbstractHttpEntity entity;
        if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            InputStream stream = GZIPHelper.compressGzip(contentEncoding, data);
            entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                ? stream.available() != 0 ? stream.available() : -1 : -1);
        } else {
            // create the Repeatable HttpEntity
            entity = new ByteArrayEntity(data);
        }
        if (exchange != null) {
View Full Code Here

        AbstractHttpEntity entity;
        if (exchange != null && !exchange.getProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.FALSE, Boolean.class)) {
            String contentEncoding = exchange.getIn().getHeader(Exchange.CONTENT_ENCODING, String.class);
            InputStream stream = GZIPHelper.compressGzip(contentEncoding, data);
            entity = new InputStreamEntity(stream, stream instanceof ByteArrayInputStream
                ? stream.available() != 0 ? stream.available() : -1 : -1);
        } else {
            // create the Repeatable HttpEntity
            entity = new ByteArrayEntity(data);
        }
        if (exchange != null) {
View Full Code Here

    private static Image getImage(String filename)
            throws FileNotFoundException, IOException {
        InputStream inputStream = new FileInputStream("images/" + filename);

        byte[] data = new byte[inputStream.available()];
        inputStream.read(data);
        inputStream.close();

        return ImagesServiceFactory.makeImage(data);
    }
View Full Code Here

  throws IOException
  {
//    return new OSCMessage( "/d_loadDir", new Object[] { new File( "synthdefs" ).getAbsolutePath() });
//    return new OSCMessage( "/d_load", new Object[] { new File( "synthdefs", "eisk-all.scsyndef" ).getAbsolutePath() });
    final InputStream  is    = getClass().getResourceAsStream( "eisk-all.scsyndef" );
    final int      size  = is.available();
    final byte[]    data  = new byte[ size ];
    is.read( data );
    is.close();
    return new OSCMessage( "/d_recv", new Object[] { data });
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.