Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_mszczonow_1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
alx_mszczonow_1
Commits
af4e34ee
Commit
af4e34ee
authored
Jul 10, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zapis z close - wyjątek i uwaga o niepoprawności
parent
82d1131e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
Zapis2.java
src/main/java/p24_pliki/Zapis2.java
+12
-0
No files found.
src/main/java/p24_pliki/Zapis2.java
View file @
af4e34ee
...
@@ -2,16 +2,28 @@ package p24_pliki;
...
@@ -2,16 +2,28 @@ package p24_pliki;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.time.LocalTime
;
public
class
Zapis2
{
public
class
Zapis2
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
LocalTime
now
=
LocalTime
.
now
();
System
.
out
.
println
(
now
);
int
sekunda
=
now
.
getSecond
()
%
10
;
System
.
out
.
println
(
"Sekunda: "
+
sekunda
);
try
{
try
{
PrintWriter
out
=
new
PrintWriter
(
"out/zapis2.txt"
);
PrintWriter
out
=
new
PrintWriter
(
"out/zapis2.txt"
);
out
.
println
(
"Ala ma kota"
);
out
.
println
(
"Ala ma kota"
);
out
.
println
(
"Ola ma psa"
);
out
.
println
(
"Ola ma psa"
);
out
.
println
(
"Odczyt czasu: "
+
now
);
out
.
println
(
"Sekunda: "
+
sekunda
);
out
.
println
(
"Wynik dzielenia: "
+
(
100
/
sekunda
));
out
.
println
(
"Ela ma chomika"
);
out
.
println
(
"Ela ma chomika"
);
out
.
println
(
"Koniec"
);
out
.
println
(
"Koniec"
);
out
.
close
();
out
.
close
();
// Tak pisany close nie gwarantuje poprawnego zamknięcia pliku.
// Jeśli we wcześniejszych liniach dojdzie do wyjątku (tutaj: dzielenie przez zero)
// to plik nie zostanie zamknięty: utrata danych, wyciek zasobów...
System
.
out
.
println
(
"Gotowe"
);
System
.
out
.
println
(
"Gotowe"
);
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment