Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fuentededatos;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- public class FuenteDeDatos {
- public static void leerArchivo() {
- File archivo = null;
- FileReader fileReader = null;
- try {
- archivo = new File("Archivo.txt");
- String linea;
- fileReader = new FileReader(archivo);
- BufferedReader br = new BufferedReader(fileReader);
- while ((linea = br.readLine()) != null) {
- System.out.println(linea);
- }
- } catch (IOException e) {
- System.out.println(e);
- }
- }
- public static void escribirArchivo() {
- FileWriter archivo = null;
- PrintWriter printWriter = null;
- try {
- archivo = new FileWriter("Archivo.txt");
- printWriter = new PrintWriter(archivo);
- // for(int count = 0; count < 10; count++) {
- // printWriter.println ("Linea: " + count);
- // }
- } catch (IOException e) {
- System.out.println(e);
- } finally {
- printWriter.close();
- }
- }
- public static void main(String[] args) {
- // FuenteDeDatos f= new FuenteDeDatos();
- // f.leerArchivo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement