集册 Java实例教程 从RandomAccessFile读取4个字节并将它们连接成字符串

从RandomAccessFile读取4个字节并将它们连接成字符串

欢马劈雪     最近更新时间:2020-01-02 10:19:05

378
从RandomAccessFile读取4个字节并将它们连接成字符串


//package com.nowjava;

import java.io.IOException;

import java.io.RandomAccessFile;//来 自 N o w J a v a . c o m


public class Main {

    /**

     *   Reads 4 bytes and concatenates them into a String.

     *   This pattern is used for ID's of various kinds.

     */

    public static String read4Chars(RandomAccessFile raf)

            throws IOException {

        StringBuffer sbuf = new StringBuffer(4);

        for (int i = 0; i < 4; i++) {

            
展开阅读全文