Package java.io

Examples of java.io.InputStream.available()


                    + "\"\r\n");
            outs.writeBytes("Content-Type:   application/octet-stream\r\n\r\n");
            if(f.length() == 0)
              continue;
            InputStream is = Streams.fileIn(f);
            byte[] buffer = new byte[is.available()];
            while (true) {
              int amountRead = is.read(buffer);
              if (amountRead == -1) {
                break;
              }
View Full Code Here


  public static boolean isJDK6() {
    InputStream is = null;
    try {
      String classFileName = "/" + Lang.class.getName().replace('.', '/') + ".class";
      is = Lang.class.getClassLoader().getResourceAsStream(classFileName);
      if (is != null && is.available() > 8) {
        is.skip(7);
        return is.read() > 49;
      }
    }
    catch (Throwable e) {}
View Full Code Here

    assertNotNull(url);
    ClassLoader classLoader = URLClassLoader.newInstance(new URL[]{url});
    InputStream is = Files.findFileAsStream("org/nutz/plugin/Plugin.w",
                        classLoader.loadClass("org.nutz.lang.XXXX"));
    assertNotNull(is);
    assertEquals(is.available(), 133);
  }

  @Test
  public void test_getParent() {
    assertEquals("/a/b/c", Files.getParent("/a/b/c/d"));
View Full Code Here

       
        public DynamicTestClass(String name,int totalMembers) throws IOException {
            _name = name;
            _entries = totalMembers;
            InputStream is = getClass().getResourceAsStream("dynamicClasses/ClassStub.txt");
            int size = is.available();
            byte[] data = new byte[size];
            is.read(data);
            _stubText = new String(data);
        }
       
View Full Code Here

      StringBuilder error = new StringBuilder();
      boolean hasContent = false;
      int ch;

      while (errorStream.available() > 0 && (ch = errorStream.read()) > 0) {
        error.append((char) ch);

        if (! Character.isWhitespace((char) ch))
          hasContent = true;
      }
View Full Code Here

  public boolean isDataAvailable()
    throws IOException
  {
    InputStream is = _is;
   
    return is != null && is.available() > 0;
  }

  @Override
  public String toString()
  {
View Full Code Here

        if (val instanceof StringReaderWithLength) {
            StringReaderWithLength rd = (StringReaderWithLength) val;
            ps.setCharacterStream(column, rd, rd.getLength());
        } else if (val instanceof InputStream) {
            InputStream in = (InputStream) val;
            ps.setBinaryStream(column, in, in.available());
        } else
            ps.setObject(column, val, jdbcType);
    }
   
    /**
 
View Full Code Here

        byte[] src = "HELLO MINA!".getBytes();
        ByteBuffer bb = ByteBuffer.wrap(src);
        InputStream is = new ByteBufferInputStream(bb);
        is.skip(6);

        assertEquals(5, is.available());
        assertEquals('M', is.read());
        assertEquals('I', is.read());
        assertEquals('N', is.read());
        assertEquals('A', is.read());
View Full Code Here

       
        String configLocation = servletConfig.getInitParameter("config-location");
        if (configLocation == null) {
            try {
                InputStream is = servletConfig.getServletContext().getResourceAsStream("/WEB-INF/cxf-servlet.xml");
                if (is != null && is.available() > 0) {
                    is.close();
                    configLocation = "/WEB-INF/cxf-servlet.xml";
                }
            } catch (Exception ex) {
                //ignore
View Full Code Here

      try {
        String errstr;
        InputStream es = c.getErrorStream();
        if(es == null) errstr = "null";
        else {
          byte[] eb = new byte[es.available()];
          es.read(eb);
          errstr = new String(eb);
        }
        System.out.println("executePost failed: server sent 404\n" + errstr);
      } catch(IOException ex) {
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.