package puntosud10;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Puntosud10 {
public static void main(String[] args) {
try {
String path = "D:/prueba/";
String name = "puntos1.txt";
ArrayList<Punto> ptList = new ArrayList();
Punto pt1 = new Punto(1, 2, "rojo");
Punto pt2 = new Punto(1, 2, "rojo");
Punto pt3 = new Punto(1, 2, "rojo");
ptList.add(pt1);
ptList.add(pt2);
ptList.add(pt3);
almacenarColPuntosEnArchivo(path, name, ptList);
} catch (IOException ex) {
Logger.getLogger(Puntosud10.class.getName()).log(L evel.SEVERE, null, ex);
}
}
public static void almacenarColPuntosEnArchivo(String path, String name, ArrayList<Punto> ptList) throws IOException {
File ptFile = new File(path + name);
FileWriter fw = new FileWriter(ptFile);
for (int i = 0; i < ptList.size(); i++) {
if (i != ptList.size()) {
fw.write(ptList.get(i).obtenerCoordX() + "#");
fw.write(ptList.get(i).obtenerCoordY() + "#");
fw.write(ptList.get(i).obtenerColor() + "\n");
} else {
fw.write("");
}
}
fw.close();
}
public static ArrayList<Punto> obtenerColPuntostDeArchivo(String path, String name) throws IOException {
File ptFile = new File(path + name);
BufferedReader ptBuff = new BufferedReader(new FileReader(ptFile));
String linea = ptBuff.readLine();
ptBuff.close();
return null;
}
}
Marcadores