helloworld:i18n:java:utf8
Table des matières
DatagramPacket
Convertion d'un DatagramPacket en String
DatagramSocket socket = new DatagramSocket (PORT); byte[] buffer = new byte[1024]; DatagramPacket paquet = new DatagramPacket (buffer, buffer.length); socket.receive (paquet); String data = new String (paquet.getData (), 0, paquet.getLength (), Charset.forName ("UTF-8"));
Convertion d'un String en DatagramPacket
String messageRenvoye = new String (paquet.getData (), 0, paquet.getLength (), Charset.forName ("UTF-8")); DatagramPacket envoie = new DatagramPacket (messageRenvoye.getBytes (Charset.forName ("UTF-8")), messageRenvoye.getBytes (Charset.forName ("UTF-8")).length, paquet.getAddress (), paquet.getPort ()); socket.send (envoie);
PrintWriter
OutputStream outputStream; ... PrintWriter pstream = new PrintWriter (new OutputStreamWriter (outputStream, StandardCharsets.UTF_8), true);
BufferedReader
BufferedReader br = new BufferedReader (new InputStreamReader (new FileInputStream (fileName), Charset.forName ("UTF-8")));
helloworld/i18n/java/utf8.txt · Dernière modification : 2015/09/21 15:35 de root