aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java b/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java
index 6b28b22..96285e8 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/ByteUtil.java
@@ -397,6 +397,22 @@ public final class ByteUtil {
}
return -1;
}
+
+ /**
+ * Inserts empty data of the given length at the current position of the
+ * given buffer (moving existing data forward the given length). The limit
+ * of the buffer is adjusted by the given length. The buffer is expecting
+ * to have the required capacity available.
+ */
+ public static void insertEmptyData(ByteBuffer buffer, int len) {
+ byte[] buf = buffer.array();
+ int pos = buffer.position();
+ int limit = buffer.limit();
+ System.out.println("FOO insert " + pos + " " + len + " " + limit + " " + buffer.capacity());
+ System.arraycopy(buf, pos, buf, pos + len, limit - pos);
+ Arrays.fill(buf, pos, pos + len, (byte)0);
+ buffer.limit(limit + len);
+ }
/**
* Convert a byte buffer to a hexadecimal string for display