wise0128216712
Messages postés3Date d'inscriptiondimanche 6 avril 2008StatutMembreDernière intervention 8 mai 2008
-
8 mai 2008 à 16:51
wise0128216712
Messages postés3Date d'inscriptiondimanche 6 avril 2008StatutMembreDernière intervention 8 mai 2008
-
8 mai 2008 à 20:13
Bonjour,
Je voudrais utiliser la fonction unmarshal de la bibliothèque API (classe NormalizedStringAdapter ) mais je ne comprends pas comment faire. Le but est donc de formater une String pour qu'elle ne comporte par d'erreurs d'espaces.
Voici ce qui est dit sur l'API:
unmarshal
public [file:///D:/jdk-6-doc/docs/api/java/lang/String.html String]unmarshal([file:///D:/jdk-6-doc/docs/api/java/lang/String.html String] text)
Removes leading and trailing whitespaces of the string
given as the parameter, then replace
any tab, CR, and LF by a whitespace character ' '.
<dd><dl> * Specified by: : <dd>
unmarshal
in class
XmlAdapter<String,String>
</dd><dd>* Parameters: : <dd>
text
- The value to be converted. Can be null.
</dd><dt>
</dt><dt>Quelqu'un pourrait me donner un exemple de la manière dont on peut l'utiliser?</dt></dl>Merci d'avance,
wise
wise0128216712
Messages postés3Date d'inscriptiondimanche 6 avril 2008StatutMembreDernière intervention 8 mai 2008 8 mai 2008 à 20:13
pardon, ça marchait effectivement, mais c'est parce que je n'avais pas importé javax.xml.bind.annotation.adapters.NormalizedStringAdapter. Par contre, je ne comprends pas, ça ne fait rien!
public class CorrectionPhrase {
public static void main(String[] args) {
NormalizedStringAdapter nsa = new NormalizedStringAdapter();
Terminal.ecrireStringln("Phrase?");
String ChaineNonCorrigee= Terminal.lireString();
String ChaineCorrigee = nsa.unmarshal(ChaineNonCorrigee);
System.out.println(ChaineCorrigee);
}
}
Et ça m'affiche exactement ce que je viens de taper! Une idée?