Search in sources :

Example 11 with BytesBuilder

use of suite.primitive.Bytes.BytesBuilder in project suite by stupidsing.

the class SocketServer method read.

private Bytes read(InputStream is, int max) throws IOException {
    BytesBuilder bb = new BytesBuilder();
    byte[] buffer = new byte[Constants.bufferSize];
    int nBytesRead;
    while ((nBytesRead = is.read(buffer, 0, min(max - bb.size(), buffer.length))) != -1) {
        bb.append(buffer, 0, nBytesRead);
        if (max < bb.size())
            Fail.t("input too long");
    }
    return bb.toBytes();
}
Also used : BytesBuilder(suite.primitive.Bytes.BytesBuilder)

Example 12 with BytesBuilder

use of suite.primitive.Bytes.BytesBuilder in project suite by stupidsing.

the class FileSystemKeyUtil method toName.

public Bytes toName(List<NameKey> keys) {
    BytesBuilder bb = new BytesBuilder();
    for (NameKey key : keys) if (0 < key.size)
        bb.append(key.path.range(0, key.size));
    else
        bb.append(key.path);
    return bb.toBytes();
}
Also used : BytesBuilder(suite.primitive.Bytes.BytesBuilder)

Aggregations

BytesBuilder (suite.primitive.Bytes.BytesBuilder)12 Bytes (suite.primitive.Bytes)6 Int (suite.node.Int)2 Chars (suite.primitive.Chars)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Extent (suite.file.ExtentAllocator.Extent)1 ExtentFile (suite.file.ExtentFile)1 Node (suite.node.Node)1 Reference (suite.node.Reference)1 Tree (suite.node.Tree)1 CharsBuilder (suite.primitive.Chars.CharsBuilder)1 DataInput_ (suite.util.DataInput_)1 DataOutput_ (suite.util.DataOutput_)1 Source (suite.util.FunUtil.Source)1 Serialize (suite.util.Serialize)1