/****************************************************************************** * This program simply writes lines with the alphabet to a file. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.FileSystems; import java.nio.file.Files; import org.pureprogrammer.Utils; public class FileIO5 { static void writeTextFile(String filespec) throws IOException { BufferedWriter ofh = Files.newBufferedWriter(FileSystems.getDefault().getPath(filespec), Charset.forName("UTF-8")); ofh.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ");ofh.newLine(); ofh.write("ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ");ofh.newLine(); ofh.write("АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ");ofh.newLine(); ofh.write("゠ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタ");ofh.newLine(); ofh.write("ダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミ");ofh.newLine(); ofh.write("ムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶヷヸヹヺ・ーヽヾヿ");ofh.newLine(); try {ofh.close();} catch (IOException ex) {}; } public static void main(String[] args) { if (args.length != 1) { System.out.println(Utils.join("", "Syntax: ", "FileIO5", " {filename}")); System.exit(1); } final String FILESPEC = args[0]; try { writeTextFile(FILESPEC); } catch (IOException ex) { System.out.println(Utils.join("", "Error: ", Utils.exceptionMessage(ex))); } catch (Exception ex) { System.out.println("Unexpected File Write Error"); } } }