?public static void getCode() throws IOException{
??
?? String rootPath = "/data/src/datawarehouse/hiveext/src/main/java/com/duowan/hive/udf";
??
?? @SuppressWarnings("unchecked")
?? List<File> files = (List<File>) FileUtils.listFiles(new File(rootPath), new String[]{"java"}, true);
???
?? for(File file : files){
??? String fileName = file.getName();
????
??? String className = fileName.substring(0,fileName.indexOf("."));
???
??? String code = IOUtils.toString(FileUtils.openInputStream(file), "utf-8");
???
??? String absolutePath = file.getAbsolutePath();
???
??? System.out.println(absolutePath);
???
??? String fs = System.getProperties().getProperty("file.separator");
???
???
??? //从路径里截取包名
?
??? String packageName = absolutePath.substring(absolutePath.indexOf("java"+fs)+5, absolutePath.indexOf(fs+fileName)).replace(fs, ".");
???
??? UdfCode udfCode = new UdfCode(className, packageName, code);
??? udfCodeService.addUdfCode(udfCode);
???
?? }
??
??
?}?