Skip to content

Commit

Permalink
Update the usage of Files.readAllLines()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrserb committed Aug 22, 2021
1 parent 0d1d6d1 commit e712764
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,7 +27,6 @@

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.ZoneId;
Expand Down Expand Up @@ -79,8 +78,7 @@ private static void readLSRfile(String filename) throws Exception {
String preferred = null;
String prefix = null;

for (String line : Files.readAllLines(Paths.get(filename),
Charset.forName("UTF-8"))) {
for (String line : Files.readAllLines(Paths.get(filename))) {
line = line.toLowerCase(Locale.ROOT);
int index = line.indexOf(' ') + 1;
if (line.startsWith("file-date:")) {
Expand Down
Expand Up @@ -339,7 +339,7 @@ private int getNamespacePid(int pid) throws AttachNotSupportedException, IOExcep
Path statusPath = Paths.get(statusFile);

try {
for (String line : Files.readAllLines(statusPath, UTF_8)) {
for (String line : Files.readAllLines(statusPath)) {
String[] parts = line.split(":");
if (parts.length == 2 && parts[0].trim().equals("NSpid")) {
parts = parts[1].trim().split("\\s+");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -34,7 +34,6 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -79,7 +78,7 @@ public SjavacClient(Options options) {
String configFile = Util.extractStringOption("conf", serverConf, "");

try {
List<String> configFileLines = Files.readAllLines(Path.of(configFile), StandardCharsets.UTF_8);
List<String> configFileLines = Files.readAllLines(Path.of(configFile));
String configFileContent = String.join("\n", configFileLines);

String portfileName = Util.extractStringOptionLine("portfile", configFileContent, "");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -32,7 +32,6 @@

public class ELFFileParser {
private static ELFFileParser elfParser;
private static final String US_ASCII = "US-ASCII";

public static ELFFileParser getParser() {
if (elfParser == null) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,7 +31,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.charset.*;

/*
* Linux specific implementation of the PlatformSupport routines
Expand Down Expand Up @@ -206,7 +205,7 @@ public int getNamespaceVmId(int pid) {
}

try {
for (String line : Files.readAllLines(statusPath, StandardCharsets.UTF_8)) {
for (String line : Files.readAllLines(statusPath)) {
String[] parts = line.split(":");
if (parts.length == 2 && parts[0].trim().equals("NSpid")) {
parts = parts[1].trim().split("\\s+");
Expand Down

0 comments on commit e712764

Please sign in to comment.