Package java.io

Examples of java.io.BufferedInputStream


    }
    public static DiskCacheObject deSerialize(byte[] data) throws DiskCacheException {
        ObjectInputStream ois = null;
        try {
            ByteArrayInputStream bais = new ByteArrayInputStream(data);
            BufferedInputStream bis = new BufferedInputStream(bais);
            ois=new ObjectInputStream(bis);
            DiskCacheObject obj = (DiskCacheObject) ois.readObject();
            obj.getCacheObject().resetRefCount();
            return obj;
        } catch (IOException e) {
View Full Code Here


      ByteBuffer buffer = null;

      System.out.println("Attempting to load: " + filename);
     
      try {
        BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
       
        int bufferLength = 4096;
        byte[] readBuffer = new byte[bufferLength];
        int read = -1;
       
        while((read = bis.read(readBuffer, 0, bufferLength)) != -1) {
          baos.write(readBuffer, 0, read);
        }
       
        //done reading, close
        bis.close();
       
        // if ogg vorbis data, we need to pass it unmodified to alBufferData
        buffer = ByteBuffer.allocateDirect(baos.size());
        buffer.order(ByteOrder.nativeOrder());
        buffer.put(baos.toByteArray());
View Full Code Here

        ByteBuffer buffer = null;

        System.out.println("Attempting to load: " + filename);
       
        try {
            BufferedInputStream bis = new BufferedInputStream(WaveData.class.getClassLoader().getResourceAsStream(filename));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
           
            int bufferLength = 4096;
            byte[] readBuffer = new byte[bufferLength];
            int read = -1;
           
            while((read = bis.read(readBuffer, 0, bufferLength)) != -1) {
                baos.write(readBuffer, 0, read);
            }
           
            //done reading, close
            bis.close();
           
            // if ogg vorbis data, we need to pass it unmodified to alBufferData
            if(usingVorbis) {
              buffer = ByteBuffer.allocateDirect(baos.size());
            } else {
View Full Code Here

    try {
      InputStream source = ShadersTest.class.getResourceAsStream(file);
      if ( source == null ) // dev-mode
        source = new FileInputStream("src/java/org/lwjgl/test/opengl/shaders/" + file);

      BufferedInputStream stream = new BufferedInputStream(source);

      byte character;
      while ( (character = (byte)stream.read()) != -1 )
        fileBuffer.put(character);

      stream.close();

      fileBuffer.flip();

      byte[] array = new byte[fileBuffer.remaining()];
      fileBuffer.get(array);
View Full Code Here

        if (item.isWriteable())
        {
          item.setAttribute(LibRepositoryBoot.REPOSITORY_DOMAIN, LibRepositoryBoot.CONTENT_TYPE, mimeType);

          // write it out ..
          final InputStream stream = new BufferedInputStream(resourceData.getResourceAsStream(resourceManager));
          try
          {
            final OutputStream outputStream = new BufferedOutputStream(item.getOutputStream());
            try
            {
              IOUtils.getInstance().copyStreams(stream, outputStream);
            }
            finally
            {
              outputStream.close();
            }
          }
          finally
          {
            stream.close();
          }

          return urlRewriter.rewrite(documentContentItem, item);
        }
      }
View Full Code Here

      {
        try
        {
//          final Properties defaultEncodings = getDefaultEncodings();
          final Properties encDef = new Properties();
          final BufferedInputStream bin = new BufferedInputStream(in);
          try
          {
            encDef.load(bin);
          }
          finally
          {
            bin.close();
          }
          final Enumeration en = encDef.keys();
          while (en.hasMoreElements())
          {
            final String enc = (String) en.nextElement();
View Full Code Here

        return loadFromJar(jar, name);
    }

    // Load class or resource from a JAR file
    private byte[] loadFromJar(String jar, String name) {
        BufferedInputStream bis = null;
        ZipFile zf = null;
        try {
            zf = new ZipFile(jar);
            Enumeration<? extends ZipEntry> entries = zf.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = entries.nextElement();
                if (entry.getName().equals(name)) {
                    bis = new BufferedInputStream(zf.getInputStream(entry));
                    int size = (int) entry.getSize();
                    byte[] data = new byte[size];
                    int b = 0, eofFlag = 0;
                    while ((size - b) > 0) {
                        eofFlag = bis.read(data, b, size - b);
                        if (eofFlag == -1)
                            break;
                        b += eofFlag;
                    }
                    return data;
                }
            }
        } catch (Exception e) {
            logger.debug(e, e);
        } finally {
            try {
                if (zf != null)
                    zf.close();
                if (bis != null)
                    bis.close();
            } catch (IOException e) {
                logger.error(e, e);
            }
        }
        return null;
View Full Code Here

               
                client.notifyStarted(zf.size());
                while (list.hasMoreElements() && !canceled) {
                    ZipEntry ze = list.nextElement();
   
                    BufferedInputStream bis = new BufferedInputStream(zf.getInputStream(ze));
                    String name = ze.getName();
                   
                    client.notifyMessage(DcResources.getText("msgProcessingFileX", name));
                   
                    if (name.toLowerCase().endsWith(".xsl")) {
                        // directory name is contained in the name
                        writeToFile(bis, new File(DataCrow.reportDir, name));
                    } else if (name.toLowerCase().endsWith(".jpg")) {
                        String moduleName = name.substring(0, name.indexOf("_"));
                        Collection<DcImageIcon> c = icons.get(moduleName);
                        c = c == null ? new ArrayList<DcImageIcon>() : c;
                       
                        int size = (int) ze.getSize();
                        byte[] bytes = new byte[size];
                        bis.read(bytes);
                       
                        DcImageIcon icon = new DcImageIcon(bytes);
                        icon.setFilename(name.substring(name.indexOf("_") + 1));
                        c.add(icon);
                       
                        icons.put(moduleName, c);
                    } else if (name.toLowerCase().endsWith(".properties")) {
                        writeToFile(bis, new File(DataCrow.moduleDir, name));
                    } else if (name.toLowerCase().endsWith(".xml")) {
                        File file =  new File(System.getProperty("java.io.tmpdir"), name);
                        writeToFile(bis, file);
                        file.deleteOnExit();
                        data.put(name.substring(0, name.toLowerCase().indexOf(".xml")), file);
                    } else if (name.toLowerCase().endsWith(".jar")) {
                        // check if the custom module does not already exist
                        if (DcModules.get(name.substring(0, name.indexOf(".jar"))) == null) {
                            writeToFile(bis, new File(DataCrow.moduleDir, name));
                            ModuleJar moduleJar = new ModuleJar(name);
                            moduleJar.load();
                            modules.add(moduleJar);
                        }
                    }
                    client.notifyProcessed();
                    bis.close();
                }
               
                processData(icons, data);
                reindexModules(modules);
View Full Code Here

        if (fileName == null) {
            return new ByteArrayInputStream(small);
        }
        FileStore store = handler.openFile(fileName, "r", true);
        boolean alwaysClose = SysProperties.lobCloseBetweenReads;
        return new BufferedInputStream(new FileStoreInputStream(store, handler, compression, alwaysClose),
                Constants.IO_BUFFER_SIZE);
    }
View Full Code Here

    url_connection.connect();

    try{
      InputStream  is = url_connection.getInputStream();

      Map  reply = BDecoder.decode( new BufferedInputStream( is ));

      preProcessReply( reply, v6 );

      return( reply );
View Full Code Here

TOP

Related Classes of java.io.BufferedInputStream

Copyright © 2015 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.