Skip to content

use Files.newInputStream #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.ProviderException;
import java.util.HashMap;
Expand Down Expand Up @@ -70,7 +71,7 @@ public Credentials fetch() {
profile = "default";
}

try (InputStream is = new FileInputStream(filename)) {
try (InputStream is = Files.newInputStream(Paths.get(filename))) {
Map<String, Properties> result = unmarshal(new InputStreamReader(is, StandardCharsets.UTF_8));
Properties values = result.get(profile);
if (values == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.ProviderException;
import java.util.Locale;
Expand Down Expand Up @@ -83,7 +84,7 @@ public Credentials fetch() {
alias = "s3";
}

try (InputStream is = new FileInputStream(filename)) {
try (InputStream is = Files.newInputStream(Paths.get(filename))) {
McConfig config =
mapper.readValue(new InputStreamReader(is, StandardCharsets.UTF_8), McConfig.class);
Map<String, String> values = config.get(alias);
Expand Down
3 changes: 2 additions & 1 deletion examples/PutObjectProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

Expand All @@ -48,7 +49,7 @@ public static void main(String[] args)

File file = new File("my-filename");
InputStream pis =
new BufferedInputStream(new ProgressStream("Uploading... ", new FileInputStream(file)));
new BufferedInputStream(new ProgressStream("Uploading... ", Files.newInputStream(file.toPath())));
minioClient.putObject(
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(
pis, pis.available(), -1)
Expand Down