Package java.io

Examples of java.io.BufferedInputStream


    if (doneLoading)
      return;
    doneLoading = true;

    FileInputStream fin = null;
    BufferedInputStream bin = null;
    makeSpecialCategories();

  
    try {
      //open the file
      File configFile = FileUtil.getUserFile("categories.config");
      fin = new FileInputStream(configFile);
      bin = new BufferedInputStream(fin, 8192);
    
      Map map = BDecoder.decode(bin);

      List catList = (List) map.get("categories");
      for (int i = 0; i < catList.size(); i++) {
        Map mCategory = (Map) catList.get(i);
        try {
          String catName = new String((byte[]) mCategory.get("name"), Constants.DEFAULT_ENCODING);
         
          Long l_maxup     = (Long)mCategory.get( "maxup" );
          Long l_maxdown   = (Long)mCategory.get( "maxdown" );
          Map<String,String>  attributes = BDecoder.decodeStrings((Map)mCategory.get( "attr" ));
         
          if ( attributes == null ){
           
            attributes = new HashMap<String, String>();
          }
         
          if ( catName.equals( UNCAT_NAME )){
           
            catUncategorized.setUploadSpeed(l_maxup==null?0:l_maxup.intValue());
            catUncategorized.setDownloadSpeed(l_maxdown==null?0:l_maxdown.intValue());
            catUncategorized.setAttributes( attributes );
           
          }else if ( catName.equals( ALL_NAME )){
               
              catAll.setAttributes( attributes );

          }else{
            categories.put(
            catName,
              new CategoryImpl(
                catName,
                l_maxup==null?0:l_maxup.intValue(),
                l_maxdown==null?0:l_maxdown.intValue(),
                attributes ));
          }
        }
        catch (UnsupportedEncodingException e1) {
          //Do nothing and process next.
        }
      }
    }
    catch (FileNotFoundException e) {
      //Do nothing
    }
    catch (Exception e) {
      Debug.printStackTrace( e );
    }
    finally {
      try {
        if (bin != null)
          bin.close();
      }
      catch (Exception e) {}
      try {
        if (fin != null)
          fin.close();
View Full Code Here


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

  {
    ZipInputStream  zis = null;
   
    try{
      zis = new ZipInputStream(
          new BufferedInputStream( new FileInputStream( file ) ));
       
      byte[]    signature  = null;
     
      Signature  sig = Signature.getInstance("MD5withRSA" );
View Full Code Here

        mkdirs(targetFile.getAbsoluteFile().getParentFile());
        ByteArrayOutputStream buff = new ByteArrayOutputStream();
        try {
            println("Downloading " + fileURL);
            URL url = new URL(fileURL);
            InputStream in = new BufferedInputStream(url.openStream());
            long last = System.currentTimeMillis();
            int len = 0;
            while (true) {
                long now = System.currentTimeMillis();
                if (now > last + 1000) {
                    println("Downloaded " + len + " bytes");
                    last = now;
                }
                int x = in.read();
                len++;
                if (x < 0) {
                    break;
                }
                buff.write(x);
            }
            in.close();
        } catch (IOException e) {
            throw new RuntimeException("Error downloading " + fileURL + " to " + target, e);
        }
        byte[] data = buff.toByteArray();
        String got = getSHA1(data);
View Full Code Here

  }

  public static LogisimFile loadSub(InputStream in, Loader loader)
      throws IOException, SAXException {
    // fetch first line and then reset
    BufferedInputStream inBuffered = new BufferedInputStream(in);
    String firstLine = getFirstLine(inBuffered);

    if (firstLine == null) {
      throw new IOException("File is empty");
    } else if (firstLine.equals("Logisim v1.0")) {
View Full Code Here

  private DayProgramScheme[] loadDayProgramSchemes() {
    String home = Plugin.getPluginManager().getTvBrowserSettings().getTvBrowserUserHome();
    File schemeFile = new File(home,SCHEME_FILE_DAYPROGRAM);
    ObjectInputStream in=null;
    try {
      in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(schemeFile), 0x4000));
      DayProgramScheme[] schemes = readDayProgramSchemesFromStream(in);
      in.close();
      return schemes;
    }catch(Exception e) {
      if (in != null) {
View Full Code Here

  private QueueScheme[] loadQueueSchemes() {
    String home = Plugin.getPluginManager().getTvBrowserSettings().getTvBrowserUserHome();
    File schemeFile = new File(home,SCHEME_FILE_QUEUE);
    ObjectInputStream in=null;
    try {
      in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(schemeFile), 0x4000));
      QueueScheme[] schemes = readQueueSchemesFromStream(in);
      in.close();
      return schemes;
    }catch(Exception e) {
      if (in != null) {
View Full Code Here

        mkdirs(targetFile.getAbsoluteFile().getParentFile());
        ByteArrayOutputStream buff = new ByteArrayOutputStream();
        try {
            println("Downloading " + fileURL);
            URL url = new URL(fileURL);
            InputStream in = new BufferedInputStream(url.openStream());
            long last = System.currentTimeMillis();
            int len = 0;
            while (true) {
                long now = System.currentTimeMillis();
                if (now > last + 1000) {
                    println("Downloaded " + len + " bytes");
                    last = now;
                }
                int x = in.read();
                len++;
                if (x < 0) {
                    break;
                }
                buff.write(x);
            }
            in.close();
        } catch (IOException e) {
            throw new RuntimeException("Error downloading", e);
        }
        byte[] data = buff.toByteArray();
        String got = getSHA1(data);
View Full Code Here


  public byte[] loadFile(String fileName) throws UpdateException {
    File file = new File(mDir, fileName);
   
    BufferedInputStream in = null;
    try {
      in = new BufferedInputStream(new FileInputStream(file), 0x4000);
      ByteArrayOutputStream out = new ByteArrayOutputStream((int) file.length());
      IOUtilities.pipeStreams(in, out);
      out.close();

      byte[] data = out.toByteArray();

      mBytesRead += data.length;
     
      return data;
    }
    catch (IOException exc) {
      throw new UpdateException("Loading file failed: " + fileName, exc);
    }
    finally {
      if (in != null) {
        try { in.close(); } catch (IOException exc) {}
      }
    }
  }
View Full Code Here

    /**
     * Constructor
     */
    public ServeInputStream(InputStream in, ServeConnection conn) {
      this.conn = conn;
      this.in = new BufferedInputStream(in);
    }
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.