simplified / fixed binary compression block with alignment
@@ -260,19 +260,8 @@ public class Util
return out(data, 1, false, fout);
}
- public static void align(ByteArrayOutputStream out, int align)
- {
- if (align > 1)
- {
- while ((out.size() % align) != 0)
- out.write(0);
- }
- }
-
- public static void outB(ByteArrayOutputStream out, short data, int align, boolean swap)
+ public static void outB(ByteArrayOutputStream out, short data, boolean swap)
{
- // does alignment
- align(out, align);
// then write data
if (swap)
{
@@ -286,20 +275,13 @@ public class Util
}
}
- public static void outB(ByteArrayOutputStream out, short data, boolean swap)
- {
- outB(out, data, 0, swap);
- }
-
public static void outB(ByteArrayOutputStream out, short data)
{
- outB(out, data, 0, false);
+ outB(out, data, false);
}
- public static void outB(ByteArrayOutputStream out, int data, int align, boolean swap)
+ public static void outB(ByteArrayOutputStream out, int data, boolean swap)
{
- // does alignment
- align(out, align);
// then write data
if (swap)
{
@@ -317,20 +299,28 @@ public class Util
}
}
- public static void outB(ByteArrayOutputStream out, int data, boolean swap)
+ public static void outB(ByteArrayOutputStream out, int data)
{
- outB(out, data, 0, swap);
+ outB(out, data, false);
}
- public static void outB(ByteArrayOutputStream out, int data)
+ public static void outB(ByteArrayOutputStream out, byte[] data, int align) throws IOException
+ {
+ // no way to know actual fill size so we reset binary data
+ if (align > 2)
{
- outB(out, data, 0, false);
+ out.reset();
+ return;
}
- public static void outB(ByteArrayOutputStream out, byte[] data, int align) throws IOException
+ // we can only handle align 2
+ if (align == 2)
{
- // does alignment
- align(out, align);
+ // do alignment
+ while ((out.size() % align) != 0)
+ out.write(0);
+ }
+
// then write data
out.write(data);
}
