File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/java/at/favre/lib/bytes Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,27 @@ public final class MutableBytes extends Bytes implements AutoCloseable {
3838 super (byteArray , byteOrder , new Factory ());
3939 }
4040
41+ /**
42+ * Creates a new instance with an empty array filled with zeros.
43+ *
44+ * @param length of the internal array
45+ * @return new instance
46+ */
47+ public static MutableBytes allocate (int length ) {
48+ return allocate (length , (byte ) 0 );
49+ }
50+
51+ /**
52+ * Creates a new instance with an empty array filled with given defaultValue
53+ *
54+ * @param length of the internal array
55+ * @param defaultValue to fill with
56+ * @return new instance
57+ */
58+ public static MutableBytes allocate (int length , byte defaultValue ) {
59+ return Bytes .allocate (length , defaultValue ).mutable ();
60+ }
61+
4162 @ Override
4263 public boolean isMutable () {
4364 return true ;
You can’t perform that action at this time.
0 commit comments