/** * This method changes a byte at an index * * @param index * @param newByte */ public void writeByte(int index, byte newByte) { // TODO: Write byte to file if (index > length) { length = index; // TODO: Add saving length to file } byte[] bytes = getBytes(); bytes[index] = newByte; setBytes(bytes); }
public Drive(int size, File drive) { length = 0; this.size = 0; this.drive = drive; byte[] bytes = new byte[size]; for (int k = 0; k < size; k++) { bytes[k] = (byte) 0; } try { drive.createNewFile(); } catch (IOException e) { e.printStackTrace(); } setBytes(bytes); }
/** This method will flip a byte */ public void flipAByte(int index) { byte[] bytes = getBytes(); bytes[index] ^= 1; setBytes(bytes); }