src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java
changeset 51650 35dee171e59c
parent 48286 745ea7d5039a
equal deleted inserted replaced
51649:8f594f75e054 51650:35dee171e59c
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    38 import java.nio.file.attribute.BasicFileAttributes;
    38 import java.nio.file.attribute.BasicFileAttributes;
    39 import java.util.Arrays;
    39 import java.util.Arrays;
    40 import java.util.Scanner;
    40 import java.util.Scanner;
    41 import java.util.function.Consumer;
    41 import java.util.function.Consumer;
    42 import java.util.stream.Collectors;
    42 import java.util.stream.Collectors;
       
    43 import java.util.stream.Stream;
    43 import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
    44 import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
    44 import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
    45 import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
    45 import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
    46 import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
    46 
    47 
    47 /**
    48 /**
   186             }
   187             }
   187         }
   188         }
   188     }
   189     }
   189 
   190 
   190     private void saveFile() {
   191     private void saveFile() {
   191         try {
   192         try (Stream<String> lines = Files.lines(tmpfile)) {
   192             saveHandler.accept(Files.lines(tmpfile).collect(Collectors.joining("\n", "", "\n")));
   193             saveHandler.accept(lines.collect(Collectors.joining("\n", "", "\n")));
   193         } catch (IOException ex) {
   194         } catch (IOException ex) {
   194             errorHandler.accept("Failure in read edit file: " + ex.getMessage());
   195             errorHandler.accept("Failure in read edit file: " + ex.getMessage());
   195         }
   196         }
   196     }
   197     }
   197 
   198