java/sql-dk/src/info/globalcode/sql/dk/Functions.java
branchv_0
changeset 33 04db6ccd6c48
parent 29 d66858b4b563
child 34 9335cf31c0f2
equal deleted inserted replaced
32:5e412dbd9362 33:04db6ccd6c48
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    17  */
    18 package info.globalcode.sql.dk;
    18 package info.globalcode.sql.dk;
    19 
    19 
    20 import info.globalcode.sql.dk.configuration.NameIdentified;
    20 import info.globalcode.sql.dk.configuration.NameIdentified;
       
    21 import java.io.BufferedReader;
       
    22 import java.io.File;
       
    23 import java.io.IOException;
       
    24 import java.io.InputStreamReader;
       
    25 import java.io.PrintWriter;
    21 import java.util.ArrayList;
    26 import java.util.ArrayList;
    22 import java.util.Collection;
    27 import java.util.Collection;
    23 import java.util.Map;
    28 import java.util.Map;
       
    29 import java.util.logging.Level;
    24 
    30 
    25 /**
    31 /**
    26  *
    32  *
    27  * @author Ing. František Kučera (frantovo.cz)
    33  * @author Ing. František Kučera (frantovo.cz)
    28  */
    34  */
    93 			}
    99 			}
    94 		}
   100 		}
    95 
   101 
    96 		return null;
   102 		return null;
    97 	}
   103 	}
       
   104 
       
   105 	/**
       
   106 	 * Copy file from Java resources to file system.
       
   107 	 */
       
   108 	public static void installResource(String resourceName, File target) throws IOException {
       
   109 		try (BufferedReader reader = new BufferedReader(new InputStreamReader(Functions.class.getClassLoader().getResourceAsStream(resourceName)))) {
       
   110 			try (PrintWriter writer = new PrintWriter(target)) {
       
   111 				while (true) {
       
   112 					String line = reader.readLine();
       
   113 					if (line == null) {
       
   114 						break;
       
   115 					} else {
       
   116 						writer.println(line);
       
   117 					}
       
   118 				}
       
   119 			}
       
   120 		}
       
   121 	}
    98 }
   122 }