summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/CLUtils.java
blob: a926e8ed4b1ca7d2d94d4884c83c9ee463a51d80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.mbien.opencl;

import java.nio.ByteBuffer;

/**
 *
 * @author Michael Bien
 */
class CLUtils {

    public static String clString2JavaString(byte[] chars, int clLength) {
        return clLength==0 ? "" : new String(chars, 0, clLength-1);
    }

    public static String clString2JavaString(ByteBuffer chars, int clLength) {
        if (clLength==0) {
            return "";
        }else{
            byte[] array = new byte[clLength-1]; // last char is always null
            chars.get(array).rewind();
            return new String(array, 0, clLength-1);
        }
    }

}