Package java.io

Examples of java.io.BufferedInputStream


    public static String getAsString(InputStream is, int blockSize)
            throws IOException {
        if (is == null)
            throw new NullPointerException("InputStream cannot be null!");

        BufferedInputStream reader = new BufferedInputStream(is);
        byte bytes[] = new byte[blockSize];
        StringBuilder sb = new StringBuilder(bytes.length);
        int ret;
        while ((ret = reader.read(bytes)) != -1) {
            sb.append(new String(bytes, 0, ret));
        }

        return sb.toString();
    }
View Full Code Here


            StreamFactoryReference sfr = streams.get(streamIndex);
            sfr.setStreamFactory(new InputStreamFactory() {
         
          @Override
          public InputStream getInputStream() throws IOException {
            return new BufferedInputStream(new FileInputStream(f)) {
              @Override
              protected void finalize() throws Throwable {
                super.finalize();
                f.delete();
              }
View Full Code Here

      throw new IllegalStateException("Error while getting a keystore ':" + e.getMessage());
    }

    // Load the keystore file
    try {
      keyStore.load(new BufferedInputStream(new FileInputStream(f)), keystorePass.toCharArray());
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException("Error while loading the keystore file '" + f + "'." + e.getMessage());
    } catch (CertificateException e) {
      throw new IllegalStateException("Error while loading the keystore file '" + f + "'." + e.getMessage());
    } catch (FileNotFoundException e) {
View Full Code Here

  }


  private ObjectInputStream getObjectInputStream(File f) throws IOException {
    return new ObjectInputStream(new BufferedInputStream(new FileInputStream(f), 0x4000));
  }
View Full Code Here

        return f.length();
      }
     
      @Override
      public InputStream getInputStream() throws IOException {
        return new BufferedInputStream(new FileInputStream(f));
      }
View Full Code Here

        }
    }

    public static InputStream convertToInputStream(byte[] data) {
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        InputStream isContent = new BufferedInputStream(bais);
        return isContent;
    }
View Full Code Here

     * designated by this <code>Blob</code> object.
     * @return length of the <code>BLOB</code> in bytes
     */
    public long length() throws SQLException{
      if (getStreamFactory().getLength() == -1) {
        InputStream is = new BufferedInputStream(getBinaryStream());
      try {
          long length = 0;
          while (is.read() != -1) {
            length++;
          }
        getStreamFactory().setLength(length);
      } catch (IOException e) {
        throw new SQLException(e);
      } finally {
        try {
          is.close();
        } catch (IOException e) {
        }
      }
      }
        return getStreamFactory().getLength();
View Full Code Here

   public void testFile() throws Exception
   {
      File file = new File(ClassLoader.getSystemResource("normal.html").getFile());
      assertEquals(true, file.exists());
      FileInputStream input = new FileInputStream(file);
      BufferedInputStream buffer = new BufferedInputStream(input);
      byte[] data = new byte[buffer.available()];
      int available = -1;

      Detector det = new Detector(PSMDetector.ALL);

      //Set an observer...
      //The Notify() will be called when a matching charset is found.
      det.init(new ICharsetDetectionObserver()
      {
         public void notify(String charset)
         {
            System.out.println("CHARSET === " + charset);
         }
      });

      boolean done = false;
      boolean isAscii = true;

      while ((available = buffer.read(data)) > -1)
      {
         //Khoilv'code.
         //System.out.print(data);
         if (isAscii)
            isAscii = det.isAscii(data, available);
View Full Code Here

     */
    public static BufferedInputStream blob2stream(Blob value) throws SQLException {
        if (value == null) {
            return null;
        }
        BufferedInputStream bufferedInStream = new BufferedInputStream(value.getBinaryStream());
        return bufferedInStream;
    }
View Full Code Here

     */
    public static BufferedInputStream stream2stream(InputStream value) {
        if (value == null) {
            return null;
        }
        BufferedInputStream bufferedInStream = new BufferedInputStream(value);
        return bufferedInStream;
    }
View Full Code Here

TOP

Related Classes of java.io.BufferedInputStream

Copyright © 2018 www.massapicom. 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.