Package java.io

Examples of java.io.DataInputStream$CacheLock


    int size = 0;
    if (siteInfo.isCustomerLogoDirty())
    {
      // Catch the IOException on this FileInputStream constructor and
      // on the read method so we can set size to zero to fall back.
      DataInputStream customerLogoStream = null;
      FileInputStream fileInputStream = null;
      try
      {
        fileInputStream = new FileInputStream(customerLogo);
        customerLogoStream = new DataInputStream(fileInputStream);
        long length = customerLogo.length();
        // make sure the long isn't bigger than maximum int value.
        if (length <= Integer.MAX_VALUE)
        {
          buffer = new byte[(int)length];
          customerLogoStream.readFully(buffer);
          // Cache the data.
          siteInfo.setCustomerLogoData(buffer);
          siteInfo.setCustomerLogoDirty(false);
          size = buffer.length;
        }
      } catch (IOException e) {
        logger.error("[service] IOException Reading CustomerLogoFile, falling back to safe default.  "+e.toString());
        size = 0;
      } finally {
        try {
          customerLogoStream.close();
          fileInputStream.close();
        } catch (Exception e) {}
      }
    } else {
      buffer = siteInfo.getCustomerLogoData();
View Full Code Here


            //The output stream must be flushed on creation in order to write some initialization data
            //through the buffered stream to the input stream on the other side
            outputStream.flush();
            final ClassLoader cl = this.getClass().getClassLoader();
            BufferedInputStream bis = new BufferedInputStream(socket.getInputStream(), STREAM_BUFFER_SIZE);
            inputStream = new ObjectDecoderInputStream(new DataInputStream(bis), cl, MAX_OBJECT_SIZE);
    }
View Full Code Here

          throw new SocketTimeoutException();
        }
        return bais.read();
      }
    };
    ObjectDecoderInputStream odis = new ObjectDecoderInputStream(new DataInputStream(is), Thread.currentThread().getContextClassLoader(), 1024);
    Object result = null;
    do {
      try {
        result = odis.readObject();
      } catch (IOException e) {
View Full Code Here

     
    }, -1);
   
    out.writeObject(clob);
   
    ObjectDecoderInputStream in = new ObjectDecoderInputStream(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())), Thread.currentThread().getContextClassLoader(), 1024);
    Object result = in.readObject();
    assertTrue(result instanceof ClobImpl);
 
View Full Code Here

        System.out.println("Listening on " + serverSocket.toString());
        long time;
        maxValue = 0;
        while (true) {
            Socket socket = serverSocket.accept();
            DataInputStream in = new DataInputStream(socket.getInputStream());
            System.out.println("Connected");
            time = System.currentTimeMillis();
            try {
                while (true) {
                    int value = in.readInt();
                    if (value < 0) {
                        break;
                    }
                    maxValue = Math.max(maxValue, value);
                }
View Full Code Here

    /**
     * Initialize the transfer object. This method will try to open an input and
     * output stream.
     */
    public void init() throws IOException {
        in = new DataInputStream(new BufferedInputStream(socket.getInputStream(), Transfer.BUFFER_SIZE));
        out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream(), Transfer.BUFFER_SIZE));
    }
View Full Code Here

   * @param file the file to read
   * @return the version value of saved file
   * @throws Exception if it fails to read value
   */
  protected float readVersionFile(File file) throws Exception {
    DataInputStream dis = new DataInputStream(new FileInputStream(file));
    float version = dis.readFloat();
    dis.close();
    return version;
  }
View Full Code Here

   * {@link IndexServer#GET_INDEX_READER}, &hellip;).
   */
  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

      return underlyingFactory.fieldType( field );
    }

    public Document getDocument( final InputStream rawContent, final Reference2ObjectMap<Enum<?>,Object> metadata ) throws IOException {
      return new AbstractDocument() {
        final DataInputStream rawContentDataInputStream = new DataInputStream( rawContent );
        int nextFieldToRead = 0;
        final MutableString uri = new MutableString();
       
        {
          uri.readSelfDelimUTF8( rawContent ).compact();
        }
       
        @Override
        public void close() throws IOException {
          super.close();
          rawContent.close();
        }
       
        public CharSequence title() {
          return (CharSequence)metadata.get( MetadataKeys.TITLE );
        }
       
        public String toString() {
          return title().toString();
        }

        public CharSequence uri() {
          return uri.length() == 0 ? null : uri;
        }
       
        /** Skips until the end of the current field, and increments <code>nextFieldToRead</code>.
         * @throws ClassNotFoundException
         * @throws IOException
         */
        private void skipOneField() throws IOException, ClassNotFoundException {
          switch( fieldType( nextFieldToRead ) ) {
          case TEXT:
            MutableString word = new MutableString();
            MutableString nonWord = new MutableString();
            do {
              word.readSelfDelimUTF8( rawContent );
              if ( exact ) nonWord.readSelfDelimUTF8( rawContent );
            } while ( word.length() > 0 || ( exact && nonWord.length() > 0 ) );
            break;
          case VIRTUAL:
            final int nfrag = rawContentDataInputStream.readInt();
            for ( int i = 0; i < 2 * nfrag; i++ ) MutableString.skipSelfDelimUTF8( rawContent );
            break;
          default: // Non-text and non-virtual
            new ObjectInputStream( rawContent ).readObject();
          }
          nextFieldToRead++;
        }
       
        /** Skips to the given field.
         *
         * @param field the field to skip to.
         * @throws IOException
         * @throws ClassNotFoundException
         */
        private void skipToField( final int field ) throws IOException, ClassNotFoundException {
          if ( nextFieldToRead > field ) throw new IllegalStateException( "Trying to skip to field " + field + " after " + nextFieldToRead );
          while ( nextFieldToRead < field ) skipOneField();
        }

        public Object content( final int field ) {
          ensureFieldIndex( field );
          Object result = null;
          if ( DEBUG ) LOGGER.debug( "Called content(" + field + "); nextField:" + nextFieldToRead );
          try {
            skipToField( field );
            if ( fieldType( nextFieldToRead ) == FieldType.VIRTUAL ) {
              final int nfrag = rawContentDataInputStream.readInt();
              MutableString doc = new MutableString();
              MutableString text = new MutableString();
              VirtualDocumentFragment[] fragArray = new VirtualDocumentFragment[ nfrag ];
              for ( int i = 0; i < nfrag; i++ ) {
                doc.readSelfDelimUTF8( rawContent );
View Full Code Here

  /** Creates a new server thread.
   * @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

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.