JAVA 问题 高手请进, 谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/05 10:05:31
Write a method that accepts a String Containing the name of a text file as a parameter and makes a copy of that file called [filename]-copy. Methods used to read and write a series of String to a text file are provided for you. If an exception is generated while the file is being written, your method output. If an exception is generated while the file is being written your method should print"output error" to standard output.

public static void main(String[]args){
copyFile("input-data.txt");
}
private static ArrayList<String>readTextFile(String filename)throws IOException{
BufferedReader buffer = new BufferedReader(new FileReader(filename));
ArrayList<String>data = new ArrayList<String>();
String line = "";
while((line = buffer.readLine()!=null)
data.add(line);
return data;
}

private static void writeTextFile(String filename,

public static void copyFile(String filename)
{
try{

writeTextFile(filename+"-copy",readTextFile(filename));
}catch(IOException e){
System.out.println("output error");
}

}

google翻译

写一个方法,接受一个字符串,它包含了作为一个参数文本文件的名称并提出了该文件的副本称为[文件名] -副本。方法用于读取和写入一系列的字符串到一个文本文件是提供给您。如果一个异常生成的,而该文件被写入,你的方法输出。如果一个异常生成的,而该文件被写入你的方法应打印“输出错误”的标准输出。

但是我不懂你什么意思?

有中文的么?