J'ai un problème. J'ai créé une application qui lit un fichier txt et scinde la phrase en utilisant la fonction de sous-chaîne. C'est le code:Fichier de type chaîne et fichier txt
public static void main(String[] args) throws IOException {
String linia = "";
Ob parser = new Ob();
try{
FileReader fr = new FileReader("C:/Dane.txt");
BufferedReader bfr = new BufferedReader(fr);
linia = bfr.readLine();
parser.spl(linia);
} catch(IOException ex){
System.out.println("Error with: "+ex);
}
}
public class Ob {
String a,b;
public void spl(String linia)
{
a = linia.substring(14, 22);
b = linia.substring(25, 34);
System.out.println(a);
System.out.println(b);
}
}
Cela fonctionne correctement, mais je veux étendre cette application. Je veux lire chaque ligne du fichier texte et enregistrer les lignes dans un tableau de chaînes. Je veux ensuite passer chaque ligne du tableau dans ma fonction spl
. Comment puis je faire ça?
Voulez-vous dire comme ça? http://stackoverflow.com/questions/5576404/i-want-to-read-a-text-file-split-it-and-store-the-results-in-an-array ou http: // stackoverflow. com/questions/5866707/performant-texte-fichier-lecture-et-parsing-split-comme-nécessaire etc? –