提交 36450dec 编写于 作者: K kohsuke

added hex dump->byte[] conversion

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13530 71c3de6d-444a-0410-be80-ed276b4c234a
上级 60465063
......@@ -446,6 +446,13 @@ public class Util {
return toHexString(bytes,0,bytes.length);
}
public static byte[] fromHexString(String data) {
byte[] r = new byte[data.length() / 2];
for (int i = 0; i < data.length(); i += 2)
r[i / 2] = (byte) Integer.parseInt(data.substring(i, i + 2), 16);
return r;
}
/**
* Returns a human readable text of the time duration.
* This version should be used for representing a duration of some activity (like build)
......
......@@ -23,11 +23,6 @@ public class HexBinaryConverter implements Converter {
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
String data = reader.getValue(); // needs to be called before hasMoreChildren.
byte[] r = new byte[data.length()/2];
for( int i=0; i<data.length(); i+=2 )
r[i/2] = (byte)Integer.parseInt(data.substring(i,i+2),16);
return r;
return Util.fromHexString(data);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册