Code:
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String test = "1234567890";
byte[] foo = test.getBytes();
String foo2String = ByteConverter.toString(foo);
System.out.println(foo2String);
String bar = new String(foo);
System.out.println(bar);
}
}
Code:
public class ByteConverter {
/** Creates a new instance of ByteConverter */
public ByteConverter() {
}
public static String toString(byte[] byteArray) {
String foo = new String(byteArray);
return foo;
}
}
Als Ausgabe erhalte ich:
49505152535455565748
1234567890
Das verstehe ich nicht ich ByteConverter.toString macht nichts anderes, die Methode ist nur Bestandteil einer anderen Klasse.