getBytes
public void getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin) Deprecated.
This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the getBytes(String enc) method, which takes a character-encoding name, or the getBytes() method, which uses the platform's default encoding.还是用getBytes(String enc)吧。或者getBytes()。
public void getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin) Deprecated.
This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the getBytes(String enc) method, which takes a character-encoding name, or the getBytes() method, which uses the platform's default encoding.还是用getBytes(String enc)吧。或者getBytes()。
可是我希望在文件中存取的
是固定长度的字符串,所以虽然deprecate也只好用了public void getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin) Deprecated.
如果保留这个方法不变,有没有什么办法能够进行转换而正确得到中文呢?
!!!!!!!!请教!!!!!!!或者我给出另外一个根源的问题 请大侠们提供一下思路
我其实是想用一个文本文件来随机存取 相同类型 的一些对象
比如说
class login
{
String name;
String password;
}
要通过对文件的随机读写操作能够添加插入删除login对象
现在用的办法就是只能将得到的不同长度字符串先进行固定大小的字节格式化
这就是我为什么坚持要用getBytes(int,int,byte[],int)的原因了
然后用RandAccessFile的对象依次调用读写,
否则不能保证存取的各个对象之间的独立性,也就是会整个乱套了请问 还有没有更好的办法解决我这个问题?
对象的序列化好像也不能用在随机读写上吧
望诸位施与援手 不胜感激