Package java.io

Examples of java.io.BufferedInputStream


        throw( new IOException( "error reading reply" ));
      }

      byte[]  reply_bytes = baos.toByteArray();

      Map reply = BDecoder.decode( new BufferedInputStream( new ByteArrayInputStream( reply_bytes )));

      preProcessReply( reply, v6 );

      return( reply );
View Full Code Here


  protected VuzeFile
  getVuzeFile(
    InputStream    is )
  {
    try{
      BufferedInputStream bis = new BufferedInputStream( is );
     
      try{
        Map  map = BDecoder.decode(bis);
       
        return( loadVuzeFile( map ));
View Full Code Here

        target  = new File( data_dir, file_prefix + ".saving" );
      }
     
      if ( target.exists()){
       
        BufferedInputStream  is = new BufferedInputStream( new FileInputStream( target ));
       
        try{
          return( BDecoder.decode( is ));
         
        }finally{
         
          is.close();
        }
      }
    }catch( Throwable e ){
     
      Debug.printStackTrace( e )
View Full Code Here

        InputStream is=null;
        Map reply = new HashMap();
        try
        {
            is = rd.download();
            reply = BDecoder.decode( new BufferedInputStream(is) );

            //all replys of this type contains a "result"
            Long res = (Long) reply.get("result");
            if(res==null)
                throw new IllegalStateException("No result parameter in the response!! reply="+reply);
View Full Code Here

   
    ZipInputStream  zis = null;
 
    try{
      zis = new ZipInputStream(
          new BufferedInputStream( new FileInputStream( contents ) ));
       
      while( true ){
       
        ZipEntry  entry = zis.getNextEntry();
         
View Full Code Here

      ResourceDownloader rd = rdf.getMetaRefreshDownloader( url_rd );
     
      InputStream is = rd.download();
     
      try{
        Map<String,Object> map = BDecoder.decode( new BufferedInputStream( is ));
       
        log( "    update check reply: " + map );
       
          // reply is either "response" meaning "no update" and giving possibly changed update secs
          // or Vuze file with updated template
View Full Code Here

    }
    clear();
    try
    {
      logger.debug("Open URL: " + url);
      final InputStream in = new BufferedInputStream(url.openStream());
      final boolean retval = readData(in);
      in.close();
      logger.debug("Loaded: " + getRowCount() + " icons");
      return retval;
    }
    catch (Exception e)
    {
View Full Code Here

        selFileName = selFileName + ConfigEditor.PROPERTIES_FILE_EXTENSION;
      }
      final Properties prop = new Properties();
      try
      {
        final InputStream in = new BufferedInputStream(new FileInputStream(selFileName));
        try
        {
          prop.load(in);
        }
        finally
        {
          in.close();
        }
      }
      catch (IOException ioe)
      {
        ConfigEditor.logger.debug(resources.getString("ConfigEditor.ERROR_0003_FAILED_TO_LOAD_PROPERTIES",
View Full Code Here

     * @return content of the file as a byte array
     * @throws Exception
     */
    public static byte[] readFile(File file) throws IOException {
        InputStream is = new FileInputStream(file);
        BufferedInputStream bis = new BufferedInputStream(is);
       
        long length = file.length();
        if (length > Integer.MAX_VALUE)
            throw new IOException("File is too large to read " + file.getName());
   
        byte[] bytes = new byte[(int)length];
   
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length && (numRead=bis.read(bytes, offset, bytes.length-offset)) >= 0)
            offset += numRead;
   
        // Ensure all the bytes have been read in
        if (offset < bytes.length)
            throw new IOException("Could not completely read file " + file.getName());
   
        bis.close();
        is.close();
       
        return bytes;   
    }
View Full Code Here

        boolean success = currentFile.renameTo(newFile);
       
        if (!success) {
            // native code failed to move the file; do it the custom way
            FileInputStream fis = new FileInputStream(currentFile);
            BufferedInputStream bis = new BufferedInputStream(fis);
       
            FileOutputStream fos = new FileOutputStream(newFile);
            BufferedOutputStream bos = new BufferedOutputStream(fos);
           
            int count = 0;
            int b;
            while ((b = bis.read()) > -1) {
                bos.write(b);
                count++;
                if (count == 2000) {
                    bos.flush();
                    count = 0;
                }
            }
           
            bos.flush();
           
            bis.close();
            bos.close();
           
            currentFile.delete();
        }
    }
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.