Java类chartobyteconverter类型已弃用 [英] Java Class chartobyteconverter Type deprecated
问题描述
我正在研究DNA蛋白质比对项目readseq。它的flybase包中包含具有charToByteConverter类的java代码,该类不编译并提供已弃用的类型消息。 (http://iubio.bio.indiana.edu/soft/molbio/readseq/java/)。
这里可以找到readseq来源我需要添加这个应用程序中有更多功能,不知道如何修复它以实现我的目标。我是java中的一种新bie。如果可能,请帮助Plz。 Readseq的网络很容易上网。
它只是将给定字符数组转换为字节。以下是有关它的一些信息:(docjar.com/docs/api/sun/io/CharToByteConverter.html)。我不知道如何处理这个被弃用的事情。
这是一个抽象类,用于:
I am working on DNA proteins alignment project "readseq" . Its "flybase " package contains java code having " charToByteConverter" class which does not compile and gives the " type deprecated " message. (http://iubio.bio.indiana.edu/soft/molbio/readseq/java/). Here readseq source can be foundI need to add some more functionality into this application, don't know how to fix it to proceed towards my goal. I am a kind of new bie in java. Plz help if possible. Readseq is with its gui is easily available on net. It just converts an array of given characters to bytes. Here is some info about it: (docjar.com/docs/api/sun/io/CharToByteConverter.html) . I don't know what to do about this being deprecated. It is an abstract class used as under:
protected byte[] getBytes(CharToByteConverter ctb) {
ctb.reset();
int estLength = ctb.getMaxBytesPerChar() * count;
byte[] result = new byte[estLength];
int length;
try {
length = ctb.convert(value, offset, offset + count,
result, 0, estLength);
length += ctb.flush(result, ctb.nextByteIndex(), estLength);
} catch (CharConversionException e) {
length = ctb.nextByteIndex();
}
if (length < estLength) {
// A short format was used: Trim the byte array.
byte[] trimResult = new byte[length];
System.arraycopy(result, 0, trimResult, 0, length);
return trimResult;
}
else {
return result;
}
}
推荐答案
javadoc评论说明了一切:
The javadoc comment says it all:
已弃用!替换 - 由java.nio.charset
Deprecated! Replaced - by java.nio.charset
在java.nio.charset包中查找替换类/方法。
Look for a replacement class/method in the java.nio.charset package.
请注意,首先使用JDK中不属于官方文档API的类是一个坏主意。
Note that using classes in the JDK that are not part of the officially documented API is a bad idea in the first place.
这篇关于Java类chartobyteconverter类型已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!