http://www.gaudry.be/���dimanche 27 mai 2012 ������������L'infobrol




  • Accueil
  • Sommaire
  • Rechercher
  • Contact
  • Forum
  • Niouzes
  • Astuces
  • NewsBrol

Pr�c�denteSuivante

�

Exemple de décodage d'une URL

Code Java (Classe Handler pour le protocole brol):
Cliquez ici pour afficher/masquer le code
  1. /**
  2. * This method decodes the URL encoded format.
  3. * i.e. %XX -> char and + to space
  4. * @param decode The String to decode.
  5. * @return The decoded String.
  6. */
  7. protected String decodeURL(String decode) {
  8. StringBuffer decoded = new StringBuffer();
  9. char nextChar;
  10. String encString;
  11. Integer encInteger;
  12.  
  13. // Go through the String character by character.
  14. for(int index=0; index < decode.length(); index++) {
  15. // Get the next character in the String.
  16. nextChar = decode.charAt(index);
  17. // If the character is +, then convert it to
  18. // a space.
  19. if (nextChar == '+') {
  20. decoded.append(" ");
  21. }
  22. // If the character is a %, then the next two
  23. // characters store the value of the encoded
  24. // character.
  25. else if (nextChar == '%') {
  26. // Create an Integer object containing the
  27. // integer value of the next two characters
  28. // in the string, assuming a base 16 notation.
  29. encInteger = Integer.valueOf(
  30. decode.substring(index+1,index+3),URL_BASE);
  31. // Increment our counter by 2 - we just read
  32. // two characters.
  33. index += 2;
  34. // Return the int value within the Integer
  35. // and then cast that into a char type.
  36. nextChar = (char)encInteger.intValue();
  37. // Add the coded character.
  38. decoded.append(nextChar);
  39. }
  40. // Otherwise, just add the character.
  41. else {
  42. decoded.append(nextChar);
  43. }
  44. }
  45. // Return the decoded string.
  46. return decoded.toString();
  47. }
  48. }
Retourner au début du code

Pr�c�denteSuivante

�



[signaler une erreur, une fote d'ortograf, consulter ou �crire un commentaire]

� Ce document issu de l′infobrol est enregistr� sous le certificat Cyber PrInterDeposit Digital Numberection. Enregistrement IDDN n� 5329
St.Gaudry�07.01.02 : Document cr�� le 02/11/2005 (derni�re modification le 17/06/2011)
Source du document imprim� : http://www.gaudry.be/_pge/java-urlencode.php
, affich� 24 fois ce mois de mai._

Recherche :

��
  • Navigation
  • Services
  • Le site
  • Matériel informatique
  • Généralités Informatique
  • Généralités OS
  • Systèmes d'exploitation
  • UNIX - Linux
  • Windows NT
  • Windows 2000
  • Programmes
  • Office
  • VBA - VBS
  • Généralités réseau
  • Normes et standards
  • Modèle OSI
  • Stat - Proba
  • Logique
  • Matrices
  • Graphes
  • Analyse
  • SGBD
  • Cryptologie
  • Compilateurs
  • Programmer
  • Programmation déclarative
  • Java
    • Tableaux
    • Les classes
    • Mots clés
    • Collections
    • API 1.5
    • packages Java
    • API JFreeChart
    • API jdom
    • API JUnit
    • API JavaMail
    • Javadoc Struts
    • Tags Struts
    • Trier en Java
    • Les flux
    • ByteStreams
    • Flux standards
    • PrintStream
    • package java.net
    • URL en Java
    • URLConnection
    • Protocol Handler
    • URLStreamHandler
    • Struts memento
    • Struts Web Exemple
    • Exercices Java
    • Ex LetterGrade
    • Ex VowelCase
    • Ex MyNumber
    • Ex Triangle
    • Ex NumberCruncher
    • Ex SellingHouses
    • Ex AbstractSorter
  • API Java
  • C & C++
  • C Sharp
  • Visual Studio
  • .NET
  • SGML HTML XML
  • CSS
  • Optimisation Web
  • Fun Web
  • PHP - MySQL
  • Manuel PHP
  • Le Web en vrac
  • Introduction au JavaScript
  • Objets JavaScript
  • JavaScript en vrac
  • Le brol du brol
  • Glossaire
  • Divertissement
  • �

    Apparence :

    Membres :

    Connexion

    Nouveaux :

    S'enregistrer

�

Infos :

15180 documents (?)
452 astuces.
549 niouzes.
3099 d�finitions.
1899 membres.
7463 messages.
Document g�n�r� en :
0.1221 seconde