Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 14 su 14
  1. #11
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    883
    ho stampato il contenuto della stringa text

  2. #12
    Utente di HTML.it L'avatar di pireda
    Registrato dal
    Jul 2001
    Messaggi
    654
    Non ci crederai ma... Adesso ho anchio la tua stessa esigenza!...
    A questo punto vorrei sapere se sei riuscito in qualche a risolvere il problema!
    Maddalena... Perché proprio Iacchetti!...

  3. #13
    Il problema lo potete risolvere con la classe StringTokenizer
    nel package java.util

    un esempio delle api docs



    StringTokenizer st = new StringTokenizer("this is a test");
    while (st.hasMoreTokens()) {
    println(st.nextToken());
    }

    prints the following output:

    this
    is
    a
    test


    per gestire \n \r ecc.... ecco la descrizione di uno dei costruttori

    StringTokenizer
    public StringTokenizer(String str) Constructs a string tokenizer for the specified string. The tokenizer uses the default delimiter set, which is " \t\n\r\f": the space character, the tab character, the newline character, the carriage-return character, and the form-feed character. Delimiter characters themselves will not be treated as tokens.


    Ciao

  4. #14
    Originariamente inviato da javamen
    Il problema lo potete risolvere con la classe StringTokenizer
    nel package java.util

    un esempio delle api docs



    StringTokenizer st = new StringTokenizer("this is a test");
    while (st.hasMoreTokens()) {
    println(st.nextToken());
    }

    prints the following output:

    this
    is
    a
    test


    per gestire \n \r ecc.... ecco la descrizione di uno dei costruttori

    StringTokenizer
    public StringTokenizer(String str) Constructs a string tokenizer for the specified string. The tokenizer uses the default delimiter set, which is " \t\n\r\f": the space character, the tab character, the newline character, the carriage-return character, and the form-feed character. Delimiter characters themselves will not be treated as tokens.


    Ciao
    esattamente...oppure potete ridefinire voi i delimitatori per esempio cosi' :

    codice:
    String DELIMITERS = " \n\t\r\f;.:";
    String s = .....;
    StringTokenizer st = new StringTokenizer ( s , DELIMITERS);
    while (st.hasMoreTokens()) {
      System.out.println(st.nextToken());
    }
    fa esattamente la stessa cosa ma in questo caso delimita anche in seguito ad alcuni segni di punteggiatura come il punto, i due punti e il punto e virgola...naturalmente l'elenco può essere esteso come si vuole...

    ciauz!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.