Package java.io

Examples of java.io.ByteArrayInputStream


              content_length -= len;
            }
           
            if ( baos != null ){
             
              post_is = new ByteArrayInputStream(baos.toByteArray());
             
            }else{
             
              fos.close();
             
              post_is = new BufferedInputStream( new FileInputStream( post_file ), 256*1024 );
            }
           
            // System.out.println( "TRTrackerServerProcessorTCP: request data = " + baos.size());
           
          }else{
           
            int  pos = header.indexOf(' ');
           
            if ( pos == -1 ){
             
              throw( new TRTrackerServerException( "header doesn't have space in right place" ));
            }
           
            timeout_ticks    = 1;
             
            lowercase_header  = header.toLowerCase();
            url_start      = pos+1;
          }
         
          setTaskState( "processing request" );
 
          current_request  = header;
         
          try{
            if ( post_is == null ){
             
                // set up a default input stream
             
              post_is = new ByteArrayInputStream(new byte[0]);
            }
           
            int  url_end = header.indexOf( " ", url_start );
           
            if ( url_end == -1 ){
View Full Code Here


          process(   request_header,
                request_header.toLowerCase(),
                url,
                (InetSocketAddress)socket_channel.socket().getRemoteSocketAddress(),
                TRTrackerServerImpl.restrict_non_blocking_requests,
                new ByteArrayInputStream(new byte[0]),
                async_control );
       
          // two ways of going async
          //  1) return is null and something else will call asyncProcessComplete later
          //  2) return is 'not-yet-filled' os and async controller is managing things
View Full Code Here

    super( "" );
    this.out = _out;
    this.azureus_core  = _azureus_core;
    this.userProfile   = UserProfile.DEFAULT_USER_PROFILE;
    this.controlling   = false;
    this.br       = new CommandReader( new InputStreamReader( new ByteArrayInputStream(new byte[0])));
       
    if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
        Appender app;
        app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
        app.setName("ConsoleAppender");
View Full Code Here

  public void testLoadSave()
  {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    manager.save(out);
    System.out.println("Saved to: " + new String(out.toByteArray()));
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    InMemoryUserManager newManager = new InMemoryUserManager(null);
    newManager.load(in);
    UserProfile profile3 = new UserProfile();
    profile3.setUserType(UserProfile.GUEST);
    profile3.setUsername("user3");
View Full Code Here

                   
                    File temp_dir = AETemporaryFileHandler.createTempDir();
                   
                    File temp_file = new File( temp_dir, id + "_" + version + "." + suffix );
                   
                    FileUtil.copyFile( new ByteArrayInputStream( plugin_file ), temp_file );

                    FilePluginInstaller installer = installFromFile( temp_file );

                    addFileInstallOperation( installer );
                   
View Full Code Here

  createFromBEncodedData(
    byte[]    data )

    throws TorrentException
  {
    ByteArrayInputStream  is = null;

    try{
      is = new ByteArrayInputStream( data );

      return( new TorrentImpl(plugin_interface,TorrentUtils.readFromBEncodedInputStream(is)));

    }catch( TOTorrentException e ){

      throw( new TorrentException( "TorrentManager::createFromBEncodedData Fails", e ));

    }finally{

      try{
        is.close();

      }catch( Throwable e ){

        Debug.printStackTrace( e );
      }
View Full Code Here

      byte[] data,
      int preserve)

      throws TorrentException
  {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    try {
      TOTorrent torrent = TOTorrentFactory.deserialiseFromBEncodedInputStream( bais );
      return new TorrentImpl(plugin_interface, preserveFields(torrent,preserve));
    } catch (TOTorrentException e) {
      throw new TorrentException ("Failed to read TorrentData", e);
    } finally {
      try {
        bais.close();
      } catch (IOException e) {}
    }
  }
View Full Code Here

        throw( new DistributedDatabaseException( "charset error", e ));
      }
    }else{
     
      try{
        ObjectInputStream  iis = new ObjectInputStream( new ByteArrayInputStream( data ));
       
        Object  res = iis.readObject();
       
        if ( target.isInstance( res )){
         
View Full Code Here

          file_bytes[1] == (byte)0xBB &&
          file_bytes[2] == (byte)0xBF ){
       
        found_bom = true;
       
        reader = new InputStreamReader( new ByteArrayInputStream( file_bytes, 3, file_bytes.length - 3 ));
       
      }else{
       
        found_bom = false;
       
        reader = new InputStreamReader( new ByteArrayInputStream( file_bytes ));

      }
         
      //max 32KB
     
View Full Code Here

      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
      cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, os);
      os.close();

      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      MarshalledValueInputStream is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();

      Object txnKey = new Object();
      loader.prepare(txnKey, mods, false);
      loader.commit(txnKey);
      try
      {
         loader.commit(txnKey);
         fail();
      }
      catch (IllegalArgumentException expected)
      {
      }
      try
      {
         loader.rollback(txnKey);
         fail();
      }
      catch (IllegalArgumentException expected)
      {
      }

      /* Commit and rollback after rollback. */
      bais = new ByteArrayInputStream(baos.toByteArray());
      is = new MarshalledValueInputStream(bais);
      loader.storeEntireState(is);
      is.close();
      txnKey = new Object();
      loader.prepare(txnKey, mods, false);
View Full Code Here

TOP

Related Classes of java.io.ByteArrayInputStream

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.