Transformer un caractere en son code ascii

nesk01 Messages postés 18 Date d'inscription jeudi 29 janvier 2004 Statut Membre Dernière intervention 17 mai 2004 - 30 janv. 2004 à 08:36
bichowdev Messages postés 2 Date d'inscription dimanche 21 novembre 2010 Statut Membre Dernière intervention 30 novembre 2010 - 30 nov. 2010 à 02:19
slt,
g une ptite kestion... : comment faire pour transformer un char en son code ascii ??
encore mieux, existe t il une fonction ki a partir d'une String creer un tableau de byte avec les valeurs ascii de chaque lettre de la string ? bon sinon j peu ecrire la methode mais il faut savoir comment recuperer l'ascii d'un char ??
merci d'avance,

Nesk01
A voir également:

8 réponses

inesbm Messages postés 4 Date d'inscription mercredi 31 octobre 2007 Statut Membre Dernière intervention 17 septembre 2008 6
12 juil. 2008 à 20:01
import java.io.*;
import java.lang.*;

  public class CharToASCII{
      public static void main(String args[]) throws IOException{
          BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Enter the char:");
          String str = buff.readLine();
          for ( int i = 0; i < str.length(); ++i ){
              char c = str.charAt(i);
              int j = (int) c;
              System.out.println("ASCII value of "+c +" is " + j + ".");
              }
      }
  }

Enjoy !
6