import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.IOException;
class ans3 {
public static void main (String args[]) {
String thisLine;
//Loop across the arguments
for (int i=0; i < args.length; i++) {
//Open the file for reading
try {
FileInputStream fin = new FileInputStream(args[i]);
FileOutputStream fout = new FileOutputStream("outdara.txt");
// now turn the FileInputStream into a DataInputStream
try {
DataInputStream myInput = new DataInputStream(fin);
PrintStream myOutput = new PrintStream(fout);
try {
while ((thisLine = myInput.readLine()) != null) {
System.out.println(thisLine);
myOutput.println(thisLine);
} // while loop ends here
}
catch (Exception e) {
System.err.println("Error: " + e);
}
} // end try
catch (Exception e) {
System.err.println("Error: " + e);
}
} // end try
catch (Exception e) {
System.err.println("failed to open file " + args[i]);
System.err.println("Error: " + e);
}
} // for end here
} // main ends here
}

沒有留言:
張貼留言