44package org .xbill .DNS ;
55
66import java .io .IOException ;
7+ import java .io .InputStream ;
78import java .util .HashSet ;
89import java .util .LinkedHashMap ;
910import java .util .LinkedList ;
@@ -170,9 +171,9 @@ protected boolean removeEldestEntry(Map.Entry eldest) {
170171 }
171172
172173 private final CacheMap data ;
174+ private final int dclass ;
173175 private int maxncache = -1 ;
174176 private int maxcache = -1 ;
175- private int dclass ;
176177
177178 private static final int defaultMaxEntries = 50000 ;
178179
@@ -198,11 +199,24 @@ public Cache() {
198199
199200 /** Creates a Cache which initially contains all records in the specified file. */
200201 public Cache (String file ) throws IOException {
201- data = new CacheMap (defaultMaxEntries );
202- try (Master m = new Master (file )) {
203- Record record ;
204- while ((record = m .nextRecord ()) != null ) {
205- addRecord (record , Credibility .HINT );
202+ this (new Master (file ));
203+ }
204+
205+ /**
206+ * Creates a Cache which initially contains all records in the specified stream.
207+ *
208+ * @since 3.6.2
209+ */
210+ public Cache (InputStream input ) throws IOException {
211+ this (new Master (input ));
212+ }
213+
214+ private <T > Cache (Master m ) throws IOException {
215+ this ();
216+ try (m ) {
217+ Record r ;
218+ while ((r = m .nextRecord ()) != null ) {
219+ addRecord (r , Credibility .HINT );
206220 }
207221 }
208222 }
0 commit comments