Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tlc4b
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
tlc4b
Commits
3d747b5b
Commit
3d747b5b
authored
10 months ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Use try-with-resources consistently
parent
200a7291
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/tlc4b/TLC4B.java
+12
-23
12 additions, 23 deletions
src/main/java/de/tlc4b/TLC4B.java
with
12 additions
and
23 deletions
src/main/java/de/tlc4b/TLC4B.java
+
12
−
23
View file @
3d747b5b
...
...
@@ -6,7 +6,9 @@ import java.io.FileOutputStream;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.Writer
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
...
...
@@ -481,9 +483,8 @@ public class TLC4B {
String
logCsvString
=
getLogCsvString
(
results
);
try
(
FileWriter
fw
=
new
FileWriter
(
logFile
,
true
))
{
// the true will append the new data
fw
.
write
(
logCsvString
);
fw
.
close
();
println
(
"Log file: "
+
logFile
.
getAbsolutePath
());
}
println
(
"Log file: "
+
logFile
.
getAbsolutePath
());
}
}
...
...
@@ -516,17 +517,13 @@ public class TLC4B {
// standard modules are copied from the standardModules folder to the current directory
File
file
=
new
File
(
path
,
name
+
".tla"
);
InputStream
is
=
null
;
FileOutputStream
fos
=
null
;
try
{
is
=
TLC4B
.
class
.
getResourceAsStream
(
"standardModules/"
+
name
+
".tla"
);
if
(
is
==
null
)
{
InputStream
resourceStream
=
TLC4B
.
class
.
getResourceAsStream
(
"standardModules/"
+
name
+
".tla"
);
if
(
resourceStream
==
null
)
{
// should never happen
throw
new
TranslationException
(
"Unable to determine the source of the standard module: "
+
name
);
}
fos
=
new
FileOutputStream
(
file
);
try
(
InputStream
is
=
resourceStream
;
OutputStream
fos
=
new
FileOutputStream
(
file
))
{
int
read
;
byte
[]
bytes
=
new
byte
[
1024
];
...
...
@@ -538,13 +535,6 @@ public class TLC4B {
if
(
TLC4BGlobals
.
isDeleteOnExit
()
&&
file
.
exists
())
{
file
.
deleteOnExit
();
}
if
(
is
!=
null
)
{
is
.
close
();
}
if
(
fos
!=
null
)
{
fos
.
flush
();
fos
.
close
();
}
}
}
...
...
@@ -553,10 +543,9 @@ public class TLC4B {
boolean
exists
=
false
;
try
{
exists
=
file
.
createNewFile
();
BufferedWriter
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
Files
.
newOutputStream
(
file
.
toPath
()),
StandardCharsets
.
UTF_8
));
try
(
Writer
out
=
new
BufferedWriter
(
new
OutputStreamWriter
(
Files
.
newOutputStream
(
file
.
toPath
()),
StandardCharsets
.
UTF_8
)))
{
out
.
write
(
text
);
out
.
close
();
}
return
file
;
}
finally
{
if
(
deleteOnExit
&&
exists
)
{
...
...
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