1. Create a program which can provide a formatted string in multiple languages. 2. You can assume that any data files us
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. Create a program which can provide a formatted string in multiple languages. 2. You can assume that any data files us
import java.io.*;
public class MyClass {
public static void main(String[] args)
{
var myself = new
MyClass();
myself.transfer();
}
public void transfer() {
FileReader in = null;
FileWriter out = null;
String inName =
"in.txt";
String outName =
"out.txt";
try {
// Open an
inputstream and output stream
in = new
FileReader(inName);
out = new
FileWriter(outName);
int c;
// Read
from in until we reach the end of file (-1)
while ((c
= in.read()) != -1) {
// Write what we have read to the output
file
out.write(c);
// Print to the screen what we have read
in
System.out.print(c);
}
}
catch
(FileNotFoundException e) {
System.out.println("Unable to find file " + inName);
e.printStackTrace();
}
catch (IOException e) {
System.out.println("I/O exception when trying to read " +
inName
+ "/write " + outName);
e.printStackTrace();
}
finally {
// Close
in
if (in !=
null) {
try {
in.close();
}
catch (IOException e) {
System.out.println("Couldn't close file " + inName);
e.printStackTrace();
}
}
// Close
out
if (out !=
null) {
try {
out.close();
}
catch (IOException e) {
System.out.println("Couldn't close file " + outName);
e.printStackTrace();
}
}
}
System.out.println();
}
}
1. Create a program which can provide a formatted string in multiple languages. 2. You can assume that any data files used in testing will contain valid data. 3. Three Java files with comments describing methods are provided, along with three data files and an FAQ: 4. You may need to create additional classes and member and/or class data. 5. Part of this exercise is identifying the appropriate class to use for each part of the problem. Hence, no UML diagram is provided. Lesson19_IOStream/09_Internationalization The following code in main() - after instantiating a Translator object - produces the output shown below. System.out.println(trans. translate(3, 8, 2021)); Terminal - -tosh - 11611 ENSF 409> java edu.ucalgary.enst409. Day Menory en-US The Bth of March will live in memory. It was on that day in 2021 that the important event happened. ENSF 489> java edu.ucalgary.enst409. Day Menory es-B0 El & de Marzo vivira en nuestra emeria; fue en este dia del 2021 que ocurrio el evento importante. ΗΤΑ Μαρτίου θα ζει στην μνήμη. Ηταν ' αυτήν την μέρα του 2021 που έγινε αυτά τα σημαντικά γεγονός. ENSF 489> java edu.ucalgary.enst 409. DayMenozy el-GR ENSF 4890 Tip: The exercise can be solved without any 1/0 classes other than those referenced in this lecture, but you may need to read additional documentation.