Package java.io

Examples of java.io.DataOutputStream


        try{
          socket.connect( new InetSocketAddress( _address, 2190 ), 5000 );
         
          socket.setSoTimeout( 5000 );
 
          DataOutputStream dos = new DataOutputStream( socket.getOutputStream());
         
          byte[]  beacon_out = _tivo_manager.encodeBeacon( false, 0 );
         
          dos.writeInt( beacon_out.length );   
       
          dos.write( beacon_out );       
           
          DataInputStream dis = new DataInputStream( socket.getInputStream());
         
          int len = dis.readInt();
       
View Full Code Here


       DHTTransportContact  contact )
     {    
    try{
         ByteArrayOutputStream  baos = new ByteArrayOutputStream();
        
         DataOutputStream  dos = new DataOutputStream(baos);
        
         dos.writeByte( 0 )// version
        
         contact.exportContact( dos );
        
         dos.close();
        
        return( baos.toByteArray());

    }catch( Throwable e ){
     
View Full Code Here

      DHTTransportContact  contact )
    {    
    try{
         ByteArrayOutputStream  baos = new ByteArrayOutputStream();
        
         DataOutputStream  dos = new DataOutputStream(baos);
               
         contact.exportContact( dos );
        
         dos.close();
        
        return( baos.toByteArray());
 
    }catch( Throwable e ){
     
View Full Code Here

    this.exact = exact;
  }

  public void open( CharSequence suffix ) throws FileNotFoundException {
    basenameSuffix = basename + suffix;
    zipDataOutputStream = new DataOutputStream( zipOut = new ZipOutputStream( new FileOutputStream( basenameSuffix + ZipDocumentCollection.ZIP_EXTENSION ) ) );
    numberOfDocuments = 0;
  }
View Full Code Here

    }

    private void startMessage(int newMessageType) {
        this.messageType = newMessageType;
        outBuffer = new ByteArrayOutputStream();
        dataOut = new DataOutputStream(outBuffer);
    }
View Full Code Here

    private void sendMessage() throws IOException {
        dataOut.flush();
        byte[] buff = outBuffer.toByteArray();
        int len = buff.length;
        dataOut = new DataOutputStream(out);
        dataOut.write(messageType);
        dataOut.writeInt(len + 4);
        dataOut.write(buff);
        dataOut.flush();
    }
View Full Code Here

            releaseLock(fp, filelock, locks);
            postFileAppend(file, startPos, len);
        }
        if(ackRequired) {
            OutputStream out = socket.getOutputStream();
            DataOutputStream dos = new DataOutputStream(out);
            dos.writeLong(len);
            postAck(file, startPos, len);
        }

        if(LOG.isDebugEnabled()) {
            SocketAddress remoteAddr = socket.getRemoteSocketAddress();
View Full Code Here

        DataInputStream din = null;
        if(sync) {
            InputStream in = socket.getInputStream();
            din = new DataInputStream(in);
        }
        final DataOutputStream dos = new DataOutputStream(out);
        final StopWatch sw = new StopWatch();
        FileInputStream src = null;
        final long nbytes;
        try {
            src = new FileInputStream(file);
            FileChannel fc = src.getChannel();

            String fileName = file.getName();
            IOUtils.writeString(fileName, dos);
            IOUtils.writeString(writeDirPath, dos);
            long xferBytes = (count == -1L) ? fc.size() : count;
            dos.writeLong(xferBytes);
            dos.writeBoolean(append); // append=false
            dos.writeBoolean(sync);
            if(handler == null) {
                dos.writeBoolean(false);
            } else {
                dos.writeBoolean(true);
                handler.writeAdditionalHeader(dos);
            }

            // send file using zero-copy send
            nbytes = fc.transferTo(fromPos, xferBytes, channel);
View Full Code Here

        DataInputStream din = null;
        if(sync) {
            InputStream in = socket.getInputStream();
            din = new DataInputStream(in);
        }
        final DataOutputStream dos = new DataOutputStream(out);
        final StopWatch sw = new StopWatch();
        try {
            IOUtils.writeString(fileName, dos);
            IOUtils.writeString(writeDirPath, dos);
            long nbytes = data.size();
            dos.writeLong(nbytes);
            dos.writeBoolean(append);
            dos.writeBoolean(sync);
            if(handler == null) {
                dos.writeBoolean(false);
            } else {
                dos.writeBoolean(true);
                handler.writeAdditionalHeader(dos);
            }

            // send file using zero-copy send
            data.writeTo(out);
View Full Code Here

      String[] children = file.getParentFile().list();
      if (children == null) return false;
      character.id = children.length + 1;
    }

    DataOutputStream output = null;
    try {
      output = new DataOutputStream(new FileOutputStream(file));
      output.writeInt(character.id);
      output.writeUTF(character.otherStuff);
      output.writeInt(character.x);
      output.writeInt(character.y);
      return true;
    } catch (IOException ex) {
      ex.printStackTrace();
      return false;
    } finally {
      try {
        output.close();
      } catch (IOException ignored) {
      }
    }
  }
View Full Code Here

TOP

Related Classes of java.io.DataOutputStream

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.