Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- public class TraitementFichier
- {
- public static int compteur = 0;
- public static void main(String[] args) throws IOException
- {
- String chaine = lireFichier("Coordonnees.csv");
- // System.out.println(compteur);
- // System.out.println(chaine);
- }
- public static List<Coordonnee> fromFichier(String nomFichier)
- {
- String chaine = lireFichier(nomFichier);
- String[] stringCoordonnee = chaine.split("\n");
- List<Coordonnee> listCoord = new ArrayList<Coordonnee>();
- for (int i = 0; i < compteur; i++)
- {
- String[] CoordonneeIndividuel = stringCoordonnee.split(";");
- Coordonnee coor = new Coordonne(CoordonneeIndividuel[0],
- CoordonneeIndividuel[1]);
- listCoord.add(coor);
- }
- return listCoord;
- }
- public static String lireFichier(String nomFichier) throws IOException
- {
- File f = new File(nomFichier);
- BufferedReader fR = new BufferedReader(new FileReader(f));
- String chaine = "";
- String chaine_totale = "";
- do
- {
- compteur++;
- chaine = fR.readLine();
- if (chaine != null)
- {
- chaine_totale += chaine + "\n";
- }
- }
- while (chaine != null);
- fR.close();
- compteur--;
- return (chaine_totale);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement