diff options
Diffstat (limited to 'src/main/java/org/openslx/util/ThriftUtil.java')
-rw-r--r-- | src/main/java/org/openslx/util/ThriftUtil.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/util/ThriftUtil.java b/src/main/java/org/openslx/util/ThriftUtil.java index 58019a7..41449ac 100644 --- a/src/main/java/org/openslx/util/ThriftUtil.java +++ b/src/main/java/org/openslx/util/ThriftUtil.java @@ -1,9 +1,13 @@ package org.openslx.util; +import java.io.BufferedReader; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; +import org.openslx.util.vm.VmwareConfig; + public class ThriftUtil { public static List<byte[]> unwrapByteBufferList(List<ByteBuffer> blockHashes) { @@ -31,4 +35,21 @@ public class ThriftUtil { return byteArray; } + public static String byteBufferToString(ByteBuffer buffer) { + byte[] bytes = unwrapByteBuffer(buffer); + BufferedReader reader; + StringBuffer content = new StringBuffer(""); + try { + reader = VmwareConfig.getVmxReader(bytes, bytes.length); + String line=""; + while ((line=reader.readLine()) != null) { + content.append(line + System.lineSeparator()); + } + reader.close(); + } catch (IOException e) { + // swallow - shouldn't happen. + return null; + } + return content.toString(); + } } |