Package java.io

Examples of java.io.DataInputStream$CacheLock


     *
     * @param in An input stream that this is chained to.
     */
    public LittleEndianInputStream(InputStream in) {
        super(in);
        this.in = new DataInputStream(in);
    }
View Full Code Here


      control_socket = new Socket( Proxy.NO_PROXY );
     
      control_socket.connect( new InetSocketAddress( socks_host, socks_port ));
   
      DataOutputStream   dos = new DataOutputStream( new BufferedOutputStream( control_socket.getOutputStream(), 256 ));
      DataInputStream   dis = new DataInputStream( control_socket.getInputStream());
           
      dos.writeByte( (byte)5 ); // socks 5
      dos.writeByte( (byte)2 ); // 2 methods
      dos.writeByte( (byte)0 ); // no auth
      dos.writeByte( (byte)2 ); // user/pw
     
      dos.flush();
     
        dis.readByte()// version byte
       
        byte method = dis.readByte();

        if ( method != 0 && method != 2 ){
         
            throw new IOException( "SOCKS 5: no valid method [" + method + "]" );
        }

          // auth
       
        if ( method == 2 ) {
           
          dos.writeByte( (byte)1 ); // user/pw version
          dos.writeByte( (byte)socks_user.length() ); // user length
          dos.write( socks_user.getBytes() );
          dos.writeByte( (byte)socks_password.length() ); // password length
          dos.write( socks_password.getBytes() );

          dos.flush();
         
          dis.readByte()// version byte
         
          byte status = dis.readByte();

            if ( status != 0 ){
             
              throw( new IOException( "SOCKS 5: authentication fails [status=" +status+ "]" ));
            }
        }
       
        String  mapped_ip;
       
        if ( target.isUnresolved() || target.getAddress() == null ){
         
            // deal with long "hostnames" that we get for, e.g., I2P destinations
         
            mapped_ip = AEProxyFactory.getAddressMapper().internalise( target.getHostName() );
           
        }else{
           
            mapped_ip = target.getAddress().getHostName();
        }
       
        dos.writeByte( (byte)5 ); // version
        dos.writeByte( (byte)3 ); // udp associate
        dos.writeByte( (byte)0 ); // reserved
       
        dos.writeByte((byte)1);
        dos.write( new byte[4] );
       
        dos.writeShort( (short)delegate.getPort()); // port
       
        dos.flush();
       
        dis.readByte()// ver
       
        byte reply = dis.readByte();
       
        if ( reply != 0 ){
         
            throw( new IOException( "SOCKS 5: udp association fails [reply=" +reply+ "]" ));
        }
       
        dis.readByte()// reserved
       
        InetAddress  relay_address;
       
        byte atype = dis.readByte();
       
        if ( atype == 1 ){
         
          byte[]  bytes = new byte[4];
         
          dis.readFully( bytes );
         
          relay_address = InetAddress.getByAddress( bytes );
         
        }else if ( atype == 3 ){
         
          byte  len = dis.readByte();
         
          byte[] bytes = new byte[(int)len&0xff ];
         
          dis.readFully( bytes );
         
          relay_address = InetAddress.getByName( new String( bytes ));
         
        }else{
         
          byte[]  bytes = new byte[16];
         
          dis.readFully( bytes );
         
          relay_address = InetAddress.getByAddress( bytes );

        }
       
        int  relay_port = ((dis.readByte()<<8)&0xff00) | (dis.readByte() & 0x00ff );
         
        if ( relay_address.isAnyLocalAddress()){
         
          relay_address = control_socket.getInetAddress();
        }
View Full Code Here

    DatagramPacket  packet )
  {
    byte[]  data     = packet.getData();
    int    data_len  = packet.getLength();
   
    DataInputStream dis = new DataInputStream( new ByteArrayInputStream( data, 0, data_len ));
   
    try{
      dis.readByte()// res
      dis.readByte()// res
      dis.readByte()// assume no frag
   
      byte  atype = dis.readByte();
     
      int  encap_len = 4;
      if ( atype == 1 ){
       
        encap_len += 4;
       
      }else if ( atype == 3 ){
       
        encap_len += 1 + (dis.readByte()&0xff);
       
      }else{
       
        encap_len += 16;
      }
View Full Code Here

            String tmp = req.getHeader("Data-Length");
            if (tmp != null) length = Integer.parseInt(tmp);
         }
         //System.out.println("readBodyContent: Length=" + length);
         byte[] ret = new byte[length];
         DataInputStream in = new DataInputStream(req.getInputStream());
         in.readFully(ret);
         return ret;
      }
      catch (Exception ex) {
         ex.printStackTrace();
         return new byte[0];
View Full Code Here

public class ObjectInputStreamMicro implements I_ObjectStream {

   private DataInputStream in;

   public ObjectInputStreamMicro(InputStream inStream) throws IOException {
      this.in = new DataInputStream(inStream);      
   }
View Full Code Here

            KeyManagerFactory kmf =
                KeyManagerFactory.getInstance(keystoreKeyManagerFactoryAlgorithm)
            KeyStore ks = KeyStore.getInstance(keyStoreType);
            FileInputStream fis = new FileInputStream(keyStoreLocation);
            DataInputStream dis = new DataInputStream(fis);
            byte[] bytes = new byte[dis.available()];
            dis.readFully(bytes);
            ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
           
            KeyManager[] keystoreManagers = null;
            if (keyStorePassword != null) {
                try {
View Full Code Here

                    try
                    {
                        server = new Socket(
                                host,
                                serverConfiguration.getPort());
                        objectInput = new ObjectInputStream(new DataInputStream(server.getInputStream()));
                        out = new ObjectOutputStream(server.getOutputStream());
                    }
                    catch (final UnknownHostException exception)
                    {
                        throw new ClientException("Can't connect to host '" + host + "'");
View Full Code Here

                            if (client != null)
                            {
                                final ObjectOutputStream serverOutput =
                                    new ObjectOutputStream(client.getOutputStream());
                                final ObjectInputStream objectInput =
                                    new ObjectInputStream(new DataInputStream(client.getInputStream()));
                                try
                                {
                                    final Object object = objectInput.readObject();
                                    if (object instanceof Configuration)
                                    {
View Full Code Here

  private void readNamespacesFromFile()
    throws IOException
  {
    synchronized (file) {
      DataInputStream in = new DataInputStream(new FileInputStream(file));

      try {
        byte[] magicNumber = IOUtil.readBytes(in, MAGIC_NUMBER.length);
        if (!Arrays.equals(magicNumber, MAGIC_NUMBER)) {
          throw new IOException("File doesn't contain compatible namespace data");
        }

        byte version = in.readByte();
        if (version > FILE_FORMAT_VERSION) {
          throw new IOException("Unable to read namespace file; it uses a newer file format");
        }
        else if (version != FILE_FORMAT_VERSION) {
          throw new IOException("Unable to read namespace file; invalid file format version: " + version);
        }

        while (true) {
          try {
            String name = in.readUTF();
            String prefix = in.readUTF();

            NamespaceImpl ns = new NamespaceImpl(prefix, name);
            namespacesMap.put(prefix, ns);
          }
          catch (EOFException e) {
            break;
          }
        }
      }
      finally {
        in.close();
      }
    }
  }
View Full Code Here

      if (formatVersion > BMSF_VERSION || formatVersion < 1) {
        throw new IOException("Incompatible format version: " + formatVersion);
      }

      // The rest of the data is GZIP-compressed
      DataInputStream dataIn = new DataInputStream(new GZIPInputStream(in));
      in = dataIn;

      int recordTypeMarker;
      while ((recordTypeMarker = dataIn.readByte()) != EOF_MARKER) {
        switch (recordTypeMarker) {
          case NAMESPACE_MARKER:
            readNamespace(dataIn);
            break;
          case EXPL_TRIPLE_MARKER:
View Full Code Here

TOP

Related Classes of java.io.DataInputStream$CacheLock

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.