< prev index next >

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java

Print this page




 227 
 228     static void log(String v) {
 229         v = addTimestamp(v);
 230         System.out.println(v);
 231         if (extraLogStream != null) {
 232             extraLogStream.println(v);
 233         }
 234     }
 235 
 236     static Path removeRootFromAbsolutePath(Path v) {
 237         if (!v.isAbsolute()) {
 238             throw new IllegalArgumentException();
 239         }
 240 
 241         if (v.getNameCount() == 0) {
 242             return Path.of("");
 243         }
 244         return v.subpath(0, v.getNameCount());
 245     }
 246 
 247     public static void createTextFile(Path propsFilename, Collection<String> lines) {
 248         createTextFile(propsFilename, lines.stream());
 249     }
 250 
 251     public static void createTextFile(Path propsFilename, Stream<String> lines) {
 252         trace(String.format("Create [%s] text file...",
 253                 propsFilename.toAbsolutePath().normalize()));
 254         ThrowingRunnable.toRunnable(() -> Files.write(propsFilename,
 255                 lines.peek(TKit::trace).collect(Collectors.toList()))).run();
 256         trace("Done");
 257     }
 258 
 259     public static void createPropertiesFile(Path propsFilename,
 260             Collection<Map.Entry<String, String>> props) {
 261         trace(String.format("Create [%s] properties file...",
 262                 propsFilename.toAbsolutePath().normalize()));
 263         ThrowingRunnable.toRunnable(() -> Files.write(propsFilename,
 264                 props.stream().map(e -> String.join("=", e.getKey(),
 265                 e.getValue())).peek(TKit::trace).collect(Collectors.toList()))).run();
 266         trace("Done");
 267     }
 268 
 269     public static void createPropertiesFile(Path propsFilename,
 270             Map.Entry<String, String>... props) {
 271         createPropertiesFile(propsFilename, List.of(props));
 272     }
 273 
 274     public static void createPropertiesFile(Path propsFilename,




 227 
 228     static void log(String v) {
 229         v = addTimestamp(v);
 230         System.out.println(v);
 231         if (extraLogStream != null) {
 232             extraLogStream.println(v);
 233         }
 234     }
 235 
 236     static Path removeRootFromAbsolutePath(Path v) {
 237         if (!v.isAbsolute()) {
 238             throw new IllegalArgumentException();
 239         }
 240 
 241         if (v.getNameCount() == 0) {
 242             return Path.of("");
 243         }
 244         return v.subpath(0, v.getNameCount());
 245     }
 246 
 247     public static void createTextFile(Path filename, Collection<String> lines) {
 248         createTextFile(filename, lines.stream());
 249     }
 250 
 251     public static void createTextFile(Path filename, Stream<String> lines) {
 252         trace(String.format("Create [%s] text file...",
 253                 filename.toAbsolutePath().normalize()));
 254         ThrowingRunnable.toRunnable(() -> Files.write(filename,
 255                 lines.peek(TKit::trace).collect(Collectors.toList()))).run();
 256         trace("Done");
 257     }
 258 
 259     public static void createPropertiesFile(Path propsFilename,
 260             Collection<Map.Entry<String, String>> props) {
 261         trace(String.format("Create [%s] properties file...",
 262                 propsFilename.toAbsolutePath().normalize()));
 263         ThrowingRunnable.toRunnable(() -> Files.write(propsFilename,
 264                 props.stream().map(e -> String.join("=", e.getKey(),
 265                 e.getValue())).peek(TKit::trace).collect(Collectors.toList()))).run();
 266         trace("Done");
 267     }
 268 
 269     public static void createPropertiesFile(Path propsFilename,
 270             Map.Entry<String, String>... props) {
 271         createPropertiesFile(propsFilename, List.of(props));
 272     }
 273 
 274     public static void createPropertiesFile(Path propsFilename,


< prev index next >