Java中是否存在基于8位字节数组的字符串类型?

Java(标准或其他)中的字符串类型/类是否基于8位字节类型的数组,而不是16位字符类型?

我非常喜欢C ++中的std :: string类型,因为它可以很好地解析base256(二进制)数据……

我继续写了一个小课程,提供了我需要的大部分function(下图),但是更好的一个将不胜感激!

public class stdstring extends Object { private byte [] bytedata; public stdstring() { bytedata = new byte[0]; } public stdstring(byte[] bytes) { bytedata = bytes; } public stdstring(byte[] bytes, int offset, int length) { bytedata = new byte[length]; System.arraycopy(bytes,offset,bytedata,0,length); } public stdstring(String string) throws UnsupportedEncodingException { bytedata = new byte[string.length()]; bytedata = string.getBytes("ISO-8859-1"); } public void assign(byte[] bytes) { bytedata = new byte[bytes.length]; bytedata = bytes; } public void assign(byte[] bytes, int offset, int length) { bytedata = new byte[length]; System.arraycopy(bytes,offset,bytedata,0,length); } public void assign(String string) throws UnsupportedEncodingException { bytedata = string.getBytes("ISO-8859-1"); } public int length() { return bytedata.length; } public byte[] getBytes() { byte [] copy = new byte[bytedata.length]; System.arraycopy(bytedata,0,copy,0,bytedata.length); return copy; } public byte[] getBytes(int offset, int length) { byte [] piece = new byte[length]; System.arraycopy(bytedata,offset,piece,0,length); return piece; } public byte getByte(int offset) { byte b = bytedata[offset]; return b; } public stdstring substring(int offset, int length) { stdstring sub = new stdstring(bytedata, offset, length); return sub; } public boolean equals(stdstring string) { if (bytedata.length != string.length()) { return false; } for (int i = 0; i < bytedata.length; ++i) { if (bytedata[i] != string.getByte(i)) { return false; } } return true; } }