Skip to content

Commit

Permalink
Replace construction of FileInputStream and FileOutputStream objects …
Browse files Browse the repository at this point in the history
…with Files NIO APIs.
  • Loading branch information
arturobernalg committed Apr 12, 2021
1 parent 0300f97 commit 91ee291
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -19,12 +19,12 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -228,13 +228,13 @@ public void load(URL url) throws IOException, NullArgumentException, ZeroExcepti
public void load(File file) throws IOException, NullArgumentException {
MathUtils.checkNotNull(file);
Charset charset = Charset.forName(FILE_CHARSET);
InputStream is = new FileInputStream(file);
InputStream is = Files.newInputStream(file.toPath());
BufferedReader in = new BufferedReader(new InputStreamReader(is, charset));
try {
DataAdapter da = new StreamDataAdapter(in);
da.computeStats();
// new adapter for second pass
is = new FileInputStream(file);
is = Files.newInputStream(file.toPath());
in = new BufferedReader(new InputStreamReader(is, charset));
fillBinStats(new StreamDataAdapter(in));
loaded = true;
Expand Down

0 comments on commit 91ee291

Please sign in to comment.