|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--multex.demo.File
Copies or moves a file, see methods main() and _usageExit() This program serves as a demonstration for the redefinition of an exception coming from a lower tier into a Failure-exception of the own abstraction level without suppressing the diagnostic information of the causing exception. Here the method copy() redefines each IOException into CopyFailure. CopyFailure extends Failure and passes the causing exception via the constructor to Failure. So it is possible in main() catching any Exception to report the complete diagnostic information both of the causing IOException and of the abstracted CopyFailure. Additionally CopyFailure has two parameters:
{0}=Name of the input file, {1}=Name of the output file
Example Dialog with JRE 1.4:
C:\>java multex.demo.File -c eingabe ausgabe
File 'input' could not be copied to 'output'
CAUSE: java.io.FileNotFoundException: input (The system can't find the indicated file)
-----Stack trace follows-----
java.io.FileNotFoundException: input (The system can't find the indicated file)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.
The shorter way to capture low level diagnostic information is used in method move(inFileName, outFileName).
move(String, String)| Nested Class Summary | |
static class |
File.CopyFailure
Indicates failure of a file copy operation. |
static class |
File.StartedExc
Indicates, that this test driver has been started. |
| Method Summary | |
static void |
copy(java.lang.String i_inFileName,
java.lang.String i_outFileName)
Effect: Copies the file i_inFileName in binary mode to file i_outFileName. |
static void |
main(java.lang.String[] i_args)
Effect: Copies or moves file i_args[1] in binary mode to file i_args[2]. |
static void |
move(java.lang.String i_inFileName,
java.lang.String i_outFileName)
Effect: Moves the file i_inFileName to file i_outFileName. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void main(java.lang.String[] i_args)
public static void copy(java.lang.String i_inFileName,
java.lang.String i_outFileName)
throws File.CopyFailure
File.CopyFailure
public static void move(java.lang.String i_inFileName,
java.lang.String i_outFileName)
throws Failure
Failure - if its is not possible to move file i_inFileName
to file i_outFileName; This way of directly throwing a multex.Failure
exception is less writing; You can nevertheless provide an individual
message text with parameterization; Internationalization is not possible
this way.File.CopyFailure
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||