Java Path File Check nio isSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization)

Here you can find the source of isSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization)

Description

is Steady State Reached

License

Mozilla Public License

Declaration

public static boolean isSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization) throws IOException 

Method Source Code

//package com.java2s;
/**/*  w  w  w.j  a  va 2  s. c  o  m*/
 * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;

import java.util.stream.Stream;

public class Main {
    public static boolean isSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization) throws IOException {
    if (Files.exists(integrationStepFile)) {
        try (Stream<String> stream = Files.lines(integrationStepFile)) {
            double[] values = stream.mapToDouble(Double::parseDouble).toArray();
            if (values.length <= 1) {
                return false;
            } else {
                // check that next to last integration step was > minStepAtEndOfStabilization s
                // last has to be avoid because can be truncated because of the end of simulation
                return values[values.length - 2] >= minStepAtEndOfStabilization;
            }
        }
    } else {
        return false;
    }
}
}

Related

  1. isPermission(Path p, Function function)
  2. isPictureFile(Path file)
  3. isRegularUsable(final Path pathToFile, final LinkOption... linkOption)
  4. isSame(Path expected, Path actual)
  5. isSameFile(Path path1, Path path2)
  6. isUNC(Path inputPath)
  7. isUnix(Path path)
  8. isValidDirectory(String path)
  9. isValidFileType(Path filePath)