Package java.io

Examples of java.io.DataInputStream


            return null;
        }

        byte[] data = createByteArray(this.dataLength - 4);
        buffer.readBytes(data);
    createRequestMessage(this.messageType, new NullTerminatedStringDataInputStream(new DataInputStream(new ByteArrayInputStream(data, 0, this.dataLength-4)), this.encoding));
    this.dataLength = null;
    this.messageType = null;
    return message;
  }
View Full Code Here


            client.initGet(remoteFile);

            // get an input stream to read data from ... AFTER we have
            // the ok to go ahead AND AFTER we've successfully opened a
            // stream for the local file
            in = new BufferedInputStream(new DataInputStream(client.getInputStream()));

        }
        catch (IOException ex) {
            client.validateTransferOnError(ex);
            throw ex;
View Full Code Here

        Set<String> known_groups = new HashSet<String>();
        private long timestamp;

        public ConnectionHandler(Socket sock) throws IOException {
            this.sock=sock;
            this.input=new DataInputStream(sock.getInputStream());
            this.output=new DataOutputStream(sock.getOutputStream());
        }
View Full Code Here

                if (this.cc != null && re.hasNextElement()) {
                    byte[] bSource = re.nextRecord();
                    re.destroy();
                    if (bSource != null) {
                        ByteArrayInputStream bais = new ByteArrayInputStream(bSource);
                        DataInputStream dis = new DataInputStream(bais);
                        int nSource = dis.readInt();
                        int nCapture = dis.readInt();
                        this.nCurrentHeight = dis.readInt();
                        this.nCurrentWidth = dis.readInt();
                        dis = null;
                        bais = null;
                        int n=0;
                        // translate stored indices for source and format back into
                        // strings
View Full Code Here

        public Object objectFromByteBuffer(byte[] buf) throws Exception {
            if(buf == null)
                return null;

            DataInputStream in=new DataInputStream(new ByteArrayInputStream(buf));
            byte type=in.readByte();
            if(type == NULL)
                return null;
            if(type == METHOD_CALL) {
                short id=in.readShort();
                short length=in.readShort();
                Object[] args=length > 0? new Object[length] : null;
                if(args != null) {
                    for(int i=0; i < args.length; i++)
                        args[i]=Util.objectFromStream(in);
                }
                return new MethodCall(id, args);
            }
            else if(type == VALUE) {
                long expiration_time=in.readLong();
                Object obj=Util.objectFromStream(in);
                return new Cache.Value(obj, expiration_time);
            }
            else
                return Util.objectFromStream(in);
View Full Code Here

        /** Code copied from handleIncomingPacket */
        public void run() {
            short                        version;
            byte                         flags;
            ExposedByteArrayInputStream  in_stream;
            DataInputStream              dis=null;

            try {
                in_stream=new ExposedByteArrayInputStream(buf, offset, length);
                dis=new DataInputStream(in_stream);
                try {
                    version=dis.readShort();
                }
                catch(IOException ex) {
                    if(discard_incompatible_packets)
                        return;
                    throw ex;
                }
                if(Version.isBinaryCompatible(version) == false) {
                    if(log.isWarnEnabled()) {
                        StringBuilder sb=new StringBuilder();
                        sb.append("packet from ").append(sender).append(" has different version (").append(Version.print(version));
                        sb.append(") from ours (").append(Version.printVersion()).append("). ");
                        if(discard_incompatible_packets)
                            sb.append("Packet is discarded");
                        else
                            sb.append("This may cause problems");
                        log.warn(sb.toString());
                    }
                    if(discard_incompatible_packets)
                        return;
                }

                flags=dis.readByte();
                boolean is_message_list=(flags & LIST) == LIST;
                boolean multicast=(flags & MULTICAST) == MULTICAST;

                if(is_message_list) { // used if message bundling is enabled
                    List<Message> msgs=readMessageList(dis);
View Full Code Here

        protected final DataOutputStream out;
        protected final UUID session_id=UUID.randomUUID();

        public Connection(Socket sock) throws IOException {
            this.sock=sock;
            this.in=new DataInputStream(sock.getInputStream());
            this.out=new DataOutputStream(sock.getOutputStream());
        }
View Full Code Here

      // transaction manager and get the configuration.
      File dir = new File(path);
      if (dir.exists() && dir.isDirectory()) {
        File tfc = new File(dir, "TFC");
        if (tfc.exists()) {
          DataInputStream dis = null;
          try {
            dis = new DataInputStream(new FileInputStream(tfc));
            String tname = dis.readUTF();
            Class tclass = Class.forName(tname);
            transaction = (Transaction) tclass.newInstance();
          } catch (Exception exc) {
            logmon.log(BasicLevel.FATAL, getName() + ", can't instantiate transaction manager", exc);
            throw new Exception("Can't instantiate transaction manager");
          } finally {
            if (dis != null) dis.close();
          }
          try {
            transaction.init(path);
          } catch (IOException exc) {
            logmon.log(BasicLevel.FATAL, getName() + ", can't start transaction manager", exc);
View Full Code Here

            try {
                byte[] bSource = rs.getRecord(this.nIdSource);
                this.szCurrentSource = new String(bSource);
                bSource = rs.getRecord(this.nIdSettings);
                ByteArrayInputStream bais = new ByteArrayInputStream(bSource);
                DataInputStream dis = new DataInputStream(bais);
                dis = null;
                bais = null;
                rs.closeRecordStore();
            } catch (Exception ex) {
                /* the record store might not be created yet. We use the
View Full Code Here

        try {
            // get an input stream to read data from ... AFTER we have
            // the ok to go ahead AND AFTER we've successfully opened a
            // stream for the local file
            in = new BufferedInputStream(
                    new DataInputStream(getInputStream()));
       
            // do the retrieving
            long monitorCount = 0;
            byte [] chunk = new byte[transferBufferSize];
            int count;
View Full Code Here

TOP

Related Classes of java.io.DataInputStream

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.