⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randomaccessfile.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  /**   * This method reads a Java <code>char</code> value from an input stream.     * It operates by reading two bytes from the stream and converting them to    * a single 16-bit Java <code>char</code>  The two bytes are stored most   * significant byte first (i.e., "big endian") regardless of the native   * host byte ordering.    * <p>   * As an example, if <code>byte1</code> and <code>byte2</code> represent    * the first   * and second byte read from the stream respectively, they will be   * transformed to a <code>char</code> in the following manner:   * <p>   * <code>(char)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>   * <p>   * This method can read a <code>char</code> written by an object    * implementing the   * <code>writeChar()</code> method in the <code>DataOutput</code> interface.   *   * @return The <code>char</code> value read    *   * @exception EOFException If end of file is reached before reading the char   * @exception IOException If any other error occurs   *   * @see DataOutput   */  public final char readChar () throws IOException  {    return in.readChar();  }  /**   * This method reads a Java double value from an input stream.  It operates   * by first reading a <code>logn</code> value from the stream by calling the   * <code>readLong()</code> method in this interface, then    * converts that <code>long</code>   * to a <code>double</code> using the <code>longBitsToDouble</code>    * method in the class <code>java.lang.Double</code>   * <p>   * This method can read a <code>double</code> written by an object    * implementing the   * <code>writeDouble()</code> method in the <code>DataOutput</code>    * interface.   *   * @return The <code>double</code> value read   *   * @exception EOFException If end of file is reached before reading    * the double   * @exception IOException If any other error occurs   *   * @see java.lang.Double   * @see DataOutput   */  public final double readDouble () throws IOException  {    return in.readDouble ();  }  /**   * This method reads a Java float value from an input stream.  It operates   * by first reading an <code>int</code> value from the stream by calling the   * <code>readInt()</code> method in this interface, then converts    * that <code>int</code>   * to a <code>float</code> using the <code>intBitsToFloat</code> method in    * the class <code>java.lang.Float</code>   * <p>   * This method can read a <code>float</code> written by an object    * implementing the   * <code>writeFloat()</code> method in the <code>DataOutput</code> interface.   *   * @return The <code>float</code> value read   *   * @exception EOFException If end of file is reached before reading the float   * @exception IOException If any other error occurs   *   * @see java.lang.Float   * @see DataOutput   */  public final float readFloat () throws IOException  {    return in.readFloat();  }  /**   * This method reads raw bytes into the passed array until the array is   * full.  Note that this method blocks until the data is available and   * throws an exception if there is not enough data left in the stream to   * fill the buffer   *   * @param buffer The buffer into which to read the data   *   * @exception EOFException If end of file is reached before filling the    * buffer   * @exception IOException If any other error occurs   */  public final void readFully (byte[] buffer) throws IOException  {    in.readFully(buffer);  }  /**   * This method reads raw bytes into the passed array <code>buf</code>    * starting   * <code>offset</code> bytes into the buffer.  The number of bytes read    * will be   * exactly <code>len</code>  Note that this method blocks until the data is    * available and throws an exception if there is not enough data left in    * the stream to read <code>len</code> bytes.   *   * @param buffer The buffer into which to read the data   * @param offset The offset into the buffer to start storing data   * @param count The number of bytes to read into the buffer   *   * @exception EOFException If end of file is reached before filling    * the buffer   * @exception IOException If any other error occurs   */  public final void readFully (byte[] buffer, int offset, int count)    throws IOException  {    in.readFully (buffer, offset, count);  }  /**   * This method reads a Java <code>int</code> value from an input stream   * It operates by reading four bytes from the stream and converting them to    * a single Java <code>int</code>  The bytes are stored most   * significant byte first (i.e., "big endian") regardless of the native   * host byte ordering.    * <p>   * As an example, if <code>byte1</code> through <code>byte4</code>    * represent the first   * four bytes read from the stream, they will be   * transformed to an <code>int</code> in the following manner:   * <p>   * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 24) + ((byte2 &amp; 0xFF) &lt;&lt; 16) +    * ((byte3 &amp; 0xFF) &lt;&lt; 8) + (byte4 &amp; 0xFF)))</code>   * <p>   * The value returned is in the range of 0 to 65535.   * <p>   * This method can read an <code>int</code> written by an object    * implementing the   * <code>writeInt()</code> method in the <code>DataOutput</code> interface.   *   * @return The <code>int</code> value read   *   * @exception EOFException If end of file is reached before reading the int   * @exception IOException If any other error occurs   *   * @see DataOutput   */  public final int readInt () throws IOException  {    return in.readInt();  }  /**   * This method reads the next line of text data from an input stream.   * It operates by reading bytes and converting those bytes to    * <code>char</code>   * values by treating the byte read as the low eight bits of the    * <code>char</code>   * and using <code>0</code> as the high eight bits.  Because of this, it does   * not support the full 16-bit Unicode character set.   * <p>   * The reading of bytes ends when either the end of file or a line terminator   * is encountered.  The bytes read are then returned as a <code>String</code>   * A line terminator is a byte sequence consisting of either    * <code>\r</code> <code>\n</code> or <code>\r\n</code>  These    * termination charaters are   * discarded and are not returned as part of the string.   * <p>   * This method can read data that was written by an object implementing the   * <code>writeLine()</code> method in <code>DataOutput</code>   *   * @return The line read as a <code>String</code>   *   * @exception IOException If an error occurs   *   * @see DataOutput   */  public final String readLine () throws IOException  {    return in.readLine ();  }  /**   * This method reads a Java long value from an input stream   * It operates by reading eight bytes from the stream and converting them to    * a single Java <code>long</code>  The bytes are stored most   * significant byte first (i.e., "big endian") regardless of the native   * host byte ordering.    * <p>   * As an example, if <code>byte1</code> through <code>byte8</code>    * represent the first   * eight bytes read from the stream, they will be   * transformed to an <code>long</code> in the following manner:   * <p>   * <code>   * (long)((((long)byte1 &amp; 0xFF) &lt;&lt; 56) + (((long)byte2 &amp; 0xFF) &lt;&lt; 48) +    * (((long)byte3 &amp; 0xFF) &lt;&lt; 40) + (((long)byte4 &amp; 0xFF) &lt;&lt; 32) +    * (((long)byte5 &amp; 0xFF) &lt;&lt; 24) + (((long)byte6 &amp; 0xFF) &lt;&lt; 16) +    * (((long)byte7 &amp; 0xFF) &lt;&lt; 8) + ((long)byte9 &amp; 0xFF)))</code>   * <p>   * The value returned is in the range of 0 to 65535.   * <p>   * This method can read an <code>long</code> written by an object    * implementing the   * <code>writeLong()</code> method in the <code>DataOutput</code> interface.   *   * @return The <code>long</code> value read   *   * @exception EOFException If end of file is reached before reading the long   * @exception IOException If any other error occurs   *   * @see DataOutput   */  public final long readLong () throws IOException  {    return in.readLong();  }  /**   * This method reads a signed 16-bit value into a Java in from the stream.   * It operates by reading two bytes from the stream and converting them to    * a single 16-bit Java <code>short</code>  The two bytes are stored most   * significant byte first (i.e., "big endian") regardless of the native   * host byte ordering.    * <p>   * As an example, if <code>byte1</code> and <code>byte2</code>    * represent the first   * and second byte read from the stream respectively, they will be   * transformed to a <code>short</code> in the following manner:   * <p>   * <code>(short)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>   * <p>   * The value returned is in the range of -32768 to 32767.   * <p>   * This method can read a <code>short</code> written by an object    * implementing the   * <code>writeShort()</code> method in the <code>DataOutput</code> interface.   *   * @return The <code>short</code> value read   *   * @exception EOFException If end of file is reached before reading the value   * @exception IOException If any other error occurs   *   * @see DataOutput   */  public final short readShort () throws IOException  {    return in.readShort();  }  /**   * This method reads 8 unsigned bits into a Java <code>int</code> value    * from the    * stream. The value returned is in the range of 0 to 255.   * <p>   * This method can read an unsigned byte written by an object implementing    * the <code>writeUnsignedByte()</code> method in the    * <code>DataOutput</code> interface.   *   * @return The unsigned bytes value read as a Java <code>int</code>   *   * @exception EOFException If end of file is reached before reading the value   * @exception IOException If any other error occurs   *   * @see DataOutput   */  public final int readUnsignedByte () throws IOException  {    return in.readUnsignedByte();  }  /**   * This method reads 16 unsigned bits into a Java int value from the stream.   * It operates by reading two bytes from the stream and converting them to    * a single Java <code>int</code>  The two bytes are stored most   * significant byte first (i.e., "big endian") regardless of the native   * host byte ordering.    * <p>   * As an example, if <code>byte1</code> and <code>byte2</code>    * represent the first   * and second byte read from the stream respectively, they will be   * transformed to an <code>int</code> in the following manner:   * <p>   * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 8) + (byte2 &amp; 0xFF))</code>   * <p>   * The value returned is in the range of 0 to 65535.   * <p>   * This method can read an unsigned short written by an object implementing   * the <code>writeUnsignedShort()</code> method in the    * <code>DataOutput</code> interface.   *   * @return The unsigned short value read as a Java <code>int</code>   *   * @exception EOFException If end of file is reached before reading the value   * @exception IOException If any other error occurs   */  public final int readUnsignedShort () throws IOException  {    return in.readUnsignedShort();  }  /**   * This method reads a <code>String</code> from an input stream that    * is encoded in   * a modified UTF-8 format.  This format has a leading two byte sequence   * that contains the remaining number of bytes to read.  This two byte   * sequence is read using the <code>readUnsignedShort()</code> method of this   * interface.   * <p>   * After the number of remaining bytes have been determined, these bytes   * are read an transformed into <code>char</code> values.     * These <code>char</code> values   * are encoded in the stream using either a one, two, or three byte format.   * The particular format in use can be determined by examining the first   * byte read.     * <p>   * If the first byte has a high order bit of 0 then   * that character consists on only one byte.  This character value consists   * of seven bits that are at positions 0 through 6 of the byte.  As an   * example, if <code>byte1</code> is the byte read from the stream, it would   * be converted to a <code>char</code> like so:   * <p>   * <code>(char)byte1</code>   * <p>   * If the first byte has <code>110</code> as its high order bits, then the    * character consists of two bytes.  The bits that make up the character   * value are in positions 0 through 4 of the first byte and bit positions

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -