salut à tous ,
quel est l'equivalent de ( etant donné que le constructeur est deprecated ):
en utilisant le constructeurCode:String s = new String ( tableauByte , 0 )
merciCode:String ( byte [] data ,String encoding )
Version imprimable
salut à tous ,
quel est l'equivalent de ( etant donné que le constructeur est deprecated ):
en utilisant le constructeurCode:String s = new String ( tableauByte , 0 )
merciCode:String ( byte [] data ,String encoding )
Bonjour,
Effectivement, le constructeur devais ne pas etre asser fiable :
javadoc :
(http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html#String(byte[],%20int))Citation:
public String(byte[] ascii,
int hibyte)
Deprecated. This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the String constructors that take a character-encoding name or that use the platform's default encoding.
je pense qu'ils parlent de ce genre de méthode :
(http://java.sun.com/j2se/1.3/docs/ap...a.lang.String))Citation:
public String(byte[] bytes,
String enc)
throws UnsupportedEncodingException
Construct a new String by converting the specified array of bytes using the specified character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the byte array.
tu es donc sensé pouvoir faire la même chose avec.
pour le paramètre enc : (enc - The name of a supported character encoding)
à voir le lien vers les noms supportés: (http://java.sun.com/j2se/1.3/docs/ap...y.html#charenc)