jdk/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java
changeset 16852 60207b2b4b42
parent 15658 55b829ca2334
child 21286 0641a36bb610
equal deleted inserted replaced
16851:3bbdae468b05 16852:60207b2b4b42
    62 package java.time.zone;
    62 package java.time.zone;
    63 
    63 
    64 import java.io.ByteArrayInputStream;
    64 import java.io.ByteArrayInputStream;
    65 import java.io.DataInputStream;
    65 import java.io.DataInputStream;
    66 import java.io.File;
    66 import java.io.File;
       
    67 import java.io.FileInputStream;
    67 import java.io.IOException;
    68 import java.io.IOException;
    68 import java.io.StreamCorruptedException;
    69 import java.io.StreamCorruptedException;
    69 import java.util.Arrays;
    70 import java.util.Arrays;
    70 import java.util.HashSet;
    71 import java.util.HashSet;
    71 import java.util.List;
    72 import java.util.List;
    73 import java.util.NavigableMap;
    74 import java.util.NavigableMap;
    74 import java.util.Objects;
    75 import java.util.Objects;
    75 import java.util.Set;
    76 import java.util.Set;
    76 import java.util.TreeMap;
    77 import java.util.TreeMap;
    77 import java.util.concurrent.ConcurrentHashMap;
    78 import java.util.concurrent.ConcurrentHashMap;
    78 import java.util.zip.ZipFile;
       
    79 
    79 
    80 /**
    80 /**
    81  * Loads time-zone rules for 'TZDB'.
    81  * Loads time-zone rules for 'TZDB'.
    82  *
    82  *
    83  * @since 1.8
    83  * @since 1.8
   104      * @throws ZoneRulesException if unable to load
   104      * @throws ZoneRulesException if unable to load
   105      */
   105      */
   106     public TzdbZoneRulesProvider() {
   106     public TzdbZoneRulesProvider() {
   107         try {
   107         try {
   108             String libDir = System.getProperty("java.home") + File.separator + "lib";
   108             String libDir = System.getProperty("java.home") + File.separator + "lib";
   109             File tzdbJar = new File(libDir, "tzdb.jar");
   109             try (DataInputStream dis = new DataInputStream(
   110             try (ZipFile zf = new ZipFile(tzdbJar);
   110                      new FileInputStream(new File(libDir, "tzdb.dat")))) {
   111                  DataInputStream dis = new DataInputStream(
       
   112                      zf.getInputStream(zf.getEntry("TZDB.dat")))) {
       
   113                 load(dis);
   111                 load(dis);
   114             }
   112             }
   115         } catch (Exception ex) {
   113         } catch (Exception ex) {
   116             throw new ZoneRulesException("Unable to load TZDB time-zone rules", ex);
   114             throw new ZoneRulesException("Unable to load TZDB time-zone rules", ex);
   117         }
   115         }