Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /**
- *
- * @author alex
- */
- public class InputStreamReaderjava {
- public static void main(String[] args) throws IOException {
- InputStreamReader in = new InputStreamReader(System.in);
- BufferedReader br = new BufferedReader(in);
- String texto, texto2;
- System.out.println("Introduce una nombre para crear...");
- texto = br.readLine();//lee buffer
- System.out.println("fichero " + texto + " creado");
- System.out.println("Introduce texto a escribir...");
- texto2 = br.readLine();
- escribir(texto,texto2);
- in.close();
- }
- public static void lecturaLineas(BufferedReader br) throws IOException {
- String linea = br.readLine();
- while (linea != null) {
- System.out.println(linea);
- linea = br.readLine();
- }
- System.out.println(linea);
- }
- public static void escribir(String texto, String texto2) throws IOException {
- try (BufferedWriter fichero = new BufferedWriter(new FileWriter(texto, true))) {
- fichero.write(texto2);
- fichero.newLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement