本文整理汇总了Java中org.apache.hadoop.hdfs.DFSUtil.bytes2byteArray方法的典型用法代码示例。如果您正苦于以下问题:Java DFSUtil.bytes2byteArray方法的具体用法?Java DFSUtil.bytes2byteArray怎么用?Java DFSUtil.bytes2byteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hdfs.DFSUtil
的用法示例。
在下文中一共展示了DFSUtil.bytes2byteArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readPathComponents
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
/**
* Reading the path from the image and converting it to byte[][] directly
* this saves us an array copy and conversions to and from String
* @param in input to read from
* @return the array each element of which is a byte[] representation
* of a path component
* @throws IOException
*/
@SuppressWarnings("deprecation")
public static byte[][] readPathComponents(DataInput in)
throws IOException {
DeprecatedUTF8 ustr = TL_DATA.get().U_STR;
ustr.readFields(in);
return DFSUtil.bytes2byteArray(ustr.getBytes(),
ustr.getLength(), (byte) Path.SEPARATOR_CHAR);
}
示例2: testString
import org.apache.hadoop.hdfs.DFSUtil; //导入方法依赖的package包/类
public void testString(String str) throws Exception {
String pathString = str;
byte[][] oldPathComponents = INode.getPathComponents(pathString);
byte[][] newPathComponents =
DFSUtil.bytes2byteArray(pathString.getBytes(Charsets.UTF_8),
(byte) Path.SEPARATOR_CHAR);
if (oldPathComponents[0] == null) {
assertTrue(oldPathComponents[0] == newPathComponents[0]);
} else {
assertTrue("Path components do not match for " + pathString,
Arrays.deepEquals(oldPathComponents, newPathComponents));
}
}