001/* 002 * Copyright 2015-2020 the original author or authors 003 * 004 * This software is licensed under the Apache License, Version 2.0, 005 * the GNU Lesser General Public License version 2 or later ("LGPL") 006 * and the WTFPL. 007 * You may choose either license to govern your use of this software only 008 * upon the condition that you accept all of the terms of either 009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL. 010 */ 011package org.minidns; 012 013import java.io.BufferedReader; 014import java.io.IOException; 015import java.io.InputStream; 016import java.io.InputStreamReader; 017import java.nio.charset.StandardCharsets; 018import java.util.logging.Level; 019import java.util.logging.Logger; 020 021public class MiniDnsInitialization { 022 023 private static final Logger LOGGER = Logger.getLogger(MiniDnsInitialization.class.getName()); 024 025 static final String VERSION; 026 027 static { 028 String miniDnsVersion; 029 BufferedReader reader = null; 030 try { 031 InputStream is = MiniDnsInitialization.class.getClassLoader().getResourceAsStream("org.minidns/version"); 032 reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); 033 miniDnsVersion = reader.readLine(); 034 } catch (Exception e) { 035 LOGGER.log(Level.SEVERE, "Could not determine MiniDNS version", e); 036 miniDnsVersion = "unkown"; 037 } finally { 038 if (reader != null) { 039 try { 040 reader.close(); 041 } catch (IOException e) { 042 LOGGER.log(Level.WARNING, "IOException closing stream", e); 043 } 044 } 045 } 046 VERSION = miniDnsVersion; 047 } 048}