Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
algodat-12-dm
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
dmeiss2s
algodat-12-dm
Commits
5dec5d4e
Commit
5dec5d4e
authored
12 years ago
by
Daniel Meißner
Browse files
Options
Downloads
Patches
Plain Diff
Added lesson 4 exercise 1
parent
a892ca01
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Aufgabenblatt_4-Aufgabe_1-Exceptions_deklarieren_und_behandeln/src/FileCopy.java
+48
-0
48 additions, 0 deletions
..._1-Exceptions_deklarieren_und_behandeln/src/FileCopy.java
with
48 additions
and
0 deletions
Aufgabenblatt_4-Aufgabe_1-Exceptions_deklarieren_und_behandeln/src/FileCopy.java
0 → 100644
+
48
−
0
View file @
5dec5d4e
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
public
class
FileCopy
{
// geprüfte exceptions
public
static
void
main
(
String
[]
args
)
throws
FileNotFoundException
,
IOException
{
FileInputStream
fis
=
null
;
FileOutputStream
fos
=
null
;
// Exception-Handler für ungeprüfte exceptions
try
{
fis
=
new
FileInputStream
(
args
[
0
]);
fos
=
new
FileOutputStream
(
args
[
1
]);
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
System
.
out
.
println
(
"Die Parameterliste beim Programmaufruf sollte sein:"
);
System
.
out
.
println
(
"java FileCopy quelldatei zieldatei"
);
return
;
}
catch
(
Exception
e
)
{
if
(
!
"0"
.
equals
(
e
.
getMessage
())
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
else
{
System
.
out
.
println
(
"Ein unerwarteter Fehler trat auf!"
);
}
return
;
}
int
c
;
c
=
fis
.
read
();
while
(
c
!=
-
1
)
{
fos
.
write
(
c
);
c
=
fis
.
read
();
}
fis
.
close
();
fos
.
close
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment