Package java.io

Examples of java.io.DataOutputStream


   * @param file the file to write out to
   * @param version the version of the applet as a float
   * @throws Exception if it fails to write file
   */
  protected void writeVersionFile(File file, float version) throws Exception {
    DataOutputStream dos = new DataOutputStream(new FileOutputStream(file));
    dos.writeFloat(version);
    dos.close();
  }
View Full Code Here


      if ( adapter_key != null ){
                       
        try{
          ByteArrayOutputStream  baos = new ByteArrayOutputStream(64);
         
          DataOutputStream  dos = new DataOutputStream( baos );
         
          adapter_key.serialiseStats( dos );
         
          dos.close();
         
          return(
            new DHTDBValueImpl[]{
              new DHTDBValueImpl(
                SystemTime.getCurrentTime(),
View Full Code Here

   */
  public RemoteIndexServerConnection( final SocketAddress address, final byte command ) throws IOException {
    socket = new Socket();
    socket.connect( address );
    inputStream = new DataInputStream( new FastBufferedInputStream( socket.getInputStream() ) );
    outputStream = new DataOutputStream( new FastBufferedOutputStream( socket.getOutputStream() ) );
    outputStream.writeByte( command );
    outputStream.flush();
  }
View Full Code Here

   * @param socket a socket in listening mode that handles client connections.
   */
  public ServerThread( final Socket socket ) throws IOException {
    this.socket = socket;
    inputStream = new DataInputStream( new BufferedInputStream( socket.getInputStream() ) );
    outputStream = new DataOutputStream( new BufferedOutputStream( socket.getOutputStream() ) );
  }
View Full Code Here

   * might be loaded anyway because the compression method for positions requires it).
   */
  public static Index getIndex( final String host, final int port, final boolean randomAccess, final boolean documentSizes ) throws IOException, ClassNotFoundException {
    final Socket socket = new Socket( host, port == -1 ? DEFAULT_PORT : port );
    LOGGER.debug( "Accessing remote index at " + host + ":" + port + "..." );
    final DataOutputStream outputStream = new DataOutputStream( socket.getOutputStream() );
    outputStream.writeByte( GET_INDEX );
    outputStream.writeBoolean( randomAccess );
    outputStream.writeBoolean( documentSizes );
    outputStream.flush();
    Index index = (Index)BinIO.loadObject( socket.getInputStream() );
    socket.close();
    LOGGER.debug( "Index at " + socket + " downloaded: " + index );
    return index;
  }
View Full Code Here

      LOGGER.debug( "Remote command: " + command );
     
      switch( command ) {
      case GET_INDEX:
        DataInputStream dis = new DataInputStream( socket.getInputStream() );
        DataOutputStream dos = new DataOutputStream( socket.getOutputStream() );
        boolean randomAccess = dis.readBoolean();
        boolean documentSizes = dis.readBoolean();
       
        if ( index instanceof BitStreamIndex && ! forceRemoteIndex ) {
          BitStreamIndex localIndex = (BitStreamIndex)index;
          if ( randomAccess && localIndex.offsets == null ) {
            randomAccess = false;
            LOGGER.warn( "Random access will not be available for index " + localIndex );
          }
          /** Note that in case of Golomb or interpolative position coding
           *  we are forced to serialise and transfer the entire size list,
           *  or decoding would be too slow. */
          BinIO.storeObject( new RemoteBitStreamIndex( localSocketAddress,
              index.numberOfDocuments, index.numberOfTerms,
              index.numberOfPostings, index.numberOfOccurrences,
              index.maxCount, localIndex.payload, localIndex.frequencyCoding, localIndex.pointerCoding,
              localIndex.countCoding,
              localIndex.positionCoding,
              localIndex.quantum,
              localIndex.height,
              localIndex.bufferSize,
              localIndex.termProcessor,
              localIndex.field,
              localIndex.properties,
              localIndex.termMap != null ? new RemoteTermMap( localSocketAddress, index.numberOfTerms ) : null,
              localIndex.prefixMap != null ? new RemotePrefixMap( localSocketAddress, index.numberOfTerms ) : null,
              localIndex.positionCoding == Coding.GOLOMB || localIndex.positionCoding == Coding.INTERPOLATIVE ? localIndex.sizes :
                ( documentSizes ? new RemoteSizeList( localSocketAddress, localIndex.numberOfDocuments ) : null ),
              randomAccess ? new RemoteOffsetList( localSocketAddress, localIndex.offsets.size() ) : null
          ), dos );
        }
        else
          BinIO.storeObject( new RemoteIndex( localSocketAddress, index.numberOfDocuments, index.numberOfTerms, index.numberOfPostings, index.numberOfOccurrences, index.maxCount, index.payload, index.hasCounts,
              index.hasPositions, index.termProcessor, index.field, ( documentSizes ? new RemoteSizeList( localSocketAddress, index.numberOfDocuments ) : null ), index.properties ), dos );
        dos.flush();
        break;
     
      case GET_INDEX_READER:
        threadPool.execute( new RemoteIndexReader.ServerThread( socket, index ) );
        break;
View Full Code Here

    documentOffsetsObs = new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.DOCUMENT_OFFSETS_EXTENSION );
    termOffsetsObs = new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.TERM_OFFSETS_EXTENSION );
    nonTermOffsetsObs = exact? new OutputBitStream( basenameSuffix + SimpleCompressedDocumentCollection.NONTERM_OFFSETS_EXTENSION ) : null;
    fieldContent = new IntArrayList();

    if ( hasNonText ) nonTextZipDataOutputStream = new DataOutputStream( nonTextZipOutputStream = new ZipOutputStream( new FastBufferedOutputStream( new FileOutputStream( basenameSuffix + ZipDocumentCollection.ZIP_EXTENSION ) ) ) );

    terms.clear();
    terms.trim( Scan.INITIAL_TERM_MAP_SIZE );
    if ( exact ) {
      nonTerms.clear();
View Full Code Here

      File  saving = new File( data_dir, "contacts.saving" );
      File  target = new File( data_dir, "contacts.dat" );

      saving.delete();
     
      DataOutputStream  dos  = null;
     
      boolean  ok = false;
     
      try{
        FileOutputStream fos = new FileOutputStream( saving );
         
        dos = new DataOutputStream(fos);
         
        dht.exportState( dos, 32 );
         
        dos.flush();
         
        fos.getFD().sync();
     
        ok  = true;
       
      }finally{
       
        if ( dos != null ){
         
          dos.close();
         
          if ( ok ){
           
            target.delete();
           
View Full Code Here

    DHTNetworkPositionProvider  provider )
  {
    try{     
      ByteArrayOutputStream  baos = new ByteArrayOutputStream();
     
      DataOutputStream  dos = new DataOutputStream( baos );
     
      provider.shutDown( dos );
     
      dos.flush();
     
      byte[]  data = baos.toByteArray();
     
      storage_adapter.setStorageForKey( "NPP:" + provider.getPositionType(), data );
     
View Full Code Here

 
    throws IOException
  {
    ByteArrayOutputStream  baos = new ByteArrayOutputStream();
   
    DataOutputStream  dos = new DataOutputStream( baos );
 
    dos.writeByte( 1 )// version
    dos.writeByte( pos.getPositionType());
   
    pos.serialise( dos );
   
    dos.close();
   
    return( baos.toByteArray());
  }
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.