Ignore:
Timestamp:
2014-07-18T23:30:23+02:00 (9 years ago)
Author:
Don-vip
Message:

code simplification with some Java 7 new NIO2 Files methods (newBufferedReader, newBufferedWriter, readAllLines)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r7314 r7315  
    1010import java.io.BufferedReader;
    1111import java.io.File;
    12 import java.io.FileInputStream;
    1312import java.io.IOException;
    1413import java.io.InputStreamReader;
     
    1716import java.nio.charset.StandardCharsets;
    1817import java.nio.file.Files;
     18import java.nio.file.Path;
    1919import java.nio.file.Paths;
    2020import java.security.KeyStore;
     
    278278            String result = null;
    279279            if (path != null) {
    280                 File file = new File(path);
    281                 if (file.exists()) {
    282                     try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
     280                Path p = Paths.get(path);
     281                if (Files.exists(p)) {
     282                    try (BufferedReader reader = Files.newBufferedReader(p, StandardCharsets.UTF_8)) {
    283283                        String id = null;
    284284                        String release = null;
Note: See TracChangeset for help on using the changeset viewer.