java.io.RandomAccessFile.consolidate()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中java.io.RandomAccessFile.consolidate方法的一些代码示例,展示了RandomAccessFile.consolidate的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.consolidate方法的具体详情如下:
包路径:java.io.RandomAccessFile
类名称:RandomAccessFile
方法名:consolidate

RandomAccessFile.consolidate介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
    public int read () throws IOException {
      if (pos >= len) {
        return -1;
      } else {
        consolidate();
        return data.charAt(pos++);
// int p2 = (pos << 1);
// int result = Character.digit(data.charAt(p2), 16) * 16 +
// Character.digit(data.charAt(p2 + 1), 16);
// pos++;
// return result;
      }
    }
  }

代码示例来源:origin: libgdx/libgdx

@Override
    public int read () throws IOException {
      if (pos >= len) {
        return -1;
      } else {
        consolidate();
        return data.charAt(pos++);
// int p2 = (pos << 1);
// int result = Character.digit(data.charAt(p2), 16) * 16 +
// Character.digit(data.charAt(p2 + 1), 16);
// pos++;
// return result;
      }
    }
  }

代码示例来源:origin: libgdx/libgdx

public void setLength (long newLength) throws IOException {
    if (len != newLength) {
      consolidate();
      if (data.length() > newLength) {
        data = data.substring(0, (int)newLength);
        len = (int)newLength;
      } else {
// System.out.println("padding " + (newLength - len) + " zeros in setLength to " + newLength);
        while (len < newLength) {
          write(0);
        }
      }
    }
  }

代码示例来源:origin: libgdx/libgdx

public void setLength (long newLength) throws IOException {
    if (len != newLength) {
      consolidate();
      if (data.length() > newLength) {
        data = data.substring(0, (int)newLength);
        len = (int)newLength;
      } else {
// System.out.println("padding " + (newLength - len) + " zeros in setLength to " + newLength);
        while (len < newLength) {
          write(0);
        }
      }
    }
  }

代码示例来源:origin: libgdx/libgdx

public void write (int b) throws IOException {
      if (!writeable) {
        throw new IOException("not writeable");
      }

      if (newData == null) {
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("no buf; newDataPos: " + pos);
      } else if (newDataPos + newData.length() != pos) {
        consolidate();
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("pos mismatch; newDataPos: " + pos);
      }

      newData.append((char)(b & 255));
// newData.append("" + Character.forDigit((b >> 4) & 15, 16) +
// Character.forDigit(b & 15, 16));
      pos++;
      len = Math.max(pos, len);
      dirty = true;
    }
  }

代码示例来源:origin: libgdx/libgdx

public void write (int b) throws IOException {
      if (!writeable) {
        throw new IOException("not writeable");
      }

      if (newData == null) {
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("no buf; newDataPos: " + pos);
      } else if (newDataPos + newData.length() != pos) {
        consolidate();
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("pos mismatch; newDataPos: " + pos);
      }

      newData.append((char)(b & 255));
// newData.append("" + Character.forDigit((b >> 4) & 15, 16) +
// Character.forDigit(b & 15, 16));
      pos++;
      len = Math.max(pos, len);
      dirty = true;
    }
  }

代码示例来源:origin: libgdx/libgdx

void flush () throws IOException {
  if (!dirty) {
    return;
  }
  consolidate();
  File.LocalStorage.setItem(name, btoa(data));
  dirty = false;
}

代码示例来源:origin: libgdx/libgdx

void flush () throws IOException {
  if (!dirty) {
    return;
  }
  consolidate();
  File.LocalStorage.setItem(name, btoa(data));
  dirty = false;
}

代码示例来源:origin: thothbot/parallax

@Override
    public int read () throws IOException {
      if (pos >= len) {
        return -1;
      } else {
        consolidate();
        return data.charAt(pos++);
// int p2 = (pos << 1);
// int result = Character.digit(data.charAt(p2), 16) * 16 +
// Character.digit(data.charAt(p2 + 1), 16);
// pos++;
// return result;
      }
    }
  }

代码示例来源:origin: thothbot/parallax

public void setLength (long newLength) throws IOException {
    if (len != newLength) {
      consolidate();
      if (data.length() > newLength) {
        data = data.substring(0, (int)newLength);
        len = (int)newLength;
      } else {
// System.out.println("padding " + (newLength - len) + " zeros in setLength to " + newLength);
        while (len < newLength) {
          write(0);
        }
      }
    }
  }

代码示例来源:origin: thothbot/parallax

public void write (int b) throws IOException {
      if (!writeable) {
        throw new IOException("not writeable");
      }

      if (newData == null) {
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("no buf; newDataPos: " + pos);
      } else if (newDataPos + newData.length() != pos) {
        consolidate();
        newDataPos = pos;
        newData = new StringBuilder();
// System.out.println("pos mismatch; newDataPos: " + pos);
      }

      newData.append((char)(b & 255));
// newData.append("" + Character.forDigit((b >> 4) & 15, 16) +
// Character.forDigit(b & 15, 16));
      pos++;
      len = Math.max(pos, len);
      dirty = true;
    }
  }

代码示例来源:origin: thothbot/parallax

void flush () throws IOException {
  if (!dirty) {
    return;
  }
  consolidate();
  File.LocalStorage.setItem(name, btoa(data));
  dirty = false;
}

相关文章