Ho provato a cercare online per risolvere questa domanda ma non ho trovato nulla.Java: come dividere una stringa per un numero di caratteri?
ho scritto il seguente codice astratto di spiegare quello che sto chiedendo:
String text = "how are you?";
String[] textArray= text.splitByNumber(4); //this method is what I'm asking
textArray[0]; //it contains "how "
textArray[1]; //it contains "are "
textArray[2]; //it contains "you?"
Il metodo splitByNumber suddivide la stringa "testo" ogni 4 caratteri. Come posso creare questo metodo ??
Molte grazie
Per curiosità, qual è il tuo caso d'uso per questo? – Marcelo
Possibile duplicato su http://stackoverflow.com/questions/2297347/splitting-a-string-at-every-n-th-character –
Possibile duplicato di [Dividi la stringa su sottostringhe di uguale lunghezza in Java] (https: // stackoverflow.com/questions/3760152/split-string-to-equal-length-substrings-in-java) – Rumid