@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; } } }
@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; } } }
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); } } } }
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); } } } }
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; } }
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; } }
void flush () throws IOException { if (!dirty) { return; } consolidate(); File.LocalStorage.setItem(name, btoa(data)); dirty = false; }
void flush () throws IOException { if (!dirty) { return; } consolidate(); File.LocalStorage.setItem(name, btoa(data)); dirty = false; }
@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; } } }
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); } } } }
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; } }
void flush () throws IOException { if (!dirty) { return; } consolidate(); File.LocalStorage.setItem(name, btoa(data)); dirty = false; }