Files
t12ficheros-ejemplos/src/main/java/iesthiar/_343_OutputStreamWriter.java
2024-05-13 09:50:34 +02:00

24 lines
763 B
Java

package iesthiar;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class _343_OutputStreamWriter {
public static void main(String[] args) {
File f = new File("fichero.txt");
try (
FileOutputStream fos = new FileOutputStream(f, true);
OutputStreamWriter osw = new OutputStreamWriter(fos, "ISO-8859-1");
BufferedWriter bfw = new BufferedWriter(osw)) {
bfw.write("Esto es un texto");
bfw.newLine();
bfw.write("Esto es otro texto con eñe");
} catch (IOException ex) {
System.err.printf("Error:%s", ex.getMessage());
}
}
}