1 19 20 package org.polepos.teams.jdbc; 21 22 import java.io.*; 23 24 public class Jdbc { 25 26 29 private static final String [] CREATE_DIRS = new String []{ 30 "data/derby", 31 "data/mckoi" 32 }; 33 34 private final static JdbcSettings sSettings = new JdbcSettings(); 35 36 public static JdbcSettings settings() { 37 return sSettings; 38 } 39 40 static { 44 45 for(String dir : CREATE_DIRS){ 46 new File(dir).mkdirs(); 47 } 48 49 50 try { 51 52 File cfg = new File("mckoi.conf"); 53 if (!cfg.exists()) { 54 InputStream in = JdbcSettings.class.getClassLoader().getResourceAsStream( 55 "mckoi.conf"); 56 OutputStream out = new FileOutputStream(cfg); 57 58 byte[] buf = new byte[1024]; 60 int len; 61 while ((len = in.read(buf)) > 0) { 62 out.write(buf, 0, len); 63 } 64 in.close(); 65 out.close(); 66 } 67 } catch (FileNotFoundException fnfex) { 68 fnfex.printStackTrace(); 69 } catch (IOException ioex) { 70 ioex.printStackTrace(); 71 } 72 } 73 74 } 75 | Popular Tags |