/** * 以文件的方式扫描包下的所有Class文件 * * @param classes * @param packageName * @param packagePath * @param recursive */ private static void doScanPackageClassesByFile( Set<Class<?>> classes, String packageName, String packagePath, final boolean recursive) { File dir = new File(packagePath); if (!dir.exists() || !dir.isDirectory()) { return; } // 过滤当前文件夹下的所有文件 File[] dirFiles = dir.listFiles( new FileFilter() { public boolean accept(File file) { return filterFile(file, recursive); } }); for (File file : dirFiles) { if (file.isDirectory()) { doScanPackageClassesByFile( classes, packageName + "." + file.getName(), file.getAbsolutePath(), recursive); } else { String className = file.getName().substring(0, file.getName().length() - 6); try { classes.add( Thread.currentThread() .getContextClassLoader() .loadClass(packageName + '.' + className)); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } }
public String addUser() { this.user = new User(); this.user.setUsername(username); this.user.setPassword(password); if (this.userid != null && this.userid.length() > 0 || this.request.getParameter("userid") != null && this.request.getParameter("userid").length() > 0) { this.user.setId(Integer.parseInt(this.userid)); try { um.update(this.user); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } else { try { um.add(user); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } return "add"; }
// Read Block-Size lines in. public InputSplit[] getSplits(JobConf job, int numSplits) throws IOException { // Create a bloom filter // Big file, create a split for each line FileSplit[] mSplits = null; // get the file splits from the HDFS (1 split = 1 file) try { mSplits = getInputSplits( job, job.get(M_INPUT_FORMAT), job.get(M_INPUT_PATH), UVDecomposer.U_INPUT_BLOCK_SIZE * UVDecomposer.V_INPUT_BLOCK_SIZE); System.out.println("Number of mSplits: " + mSplits.length); } catch (ClassNotFoundException e) { e.printStackTrace(); } FileSplit[] uSplits = null; try { uSplits = getInputSplits( job, job.get(U_INPUT_FORMAT), job.get(U_INPUT_PATH), UVDecomposer.U_INPUT_BLOCK_SIZE); System.out.println("Number of uSplits: " + uSplits.length); } catch (ClassNotFoundException e) { e.printStackTrace(); } // Smaller file - eventually don't need to create blocks here, instead use one big split! FileSplit[] vSplits = null; try { vSplits = getInputSplits( job, job.get(V_INPUT_FORMAT), job.get(V_INPUT_PATH), UVDecomposer.V_INPUT_BLOCK_SIZE); System.out.println("Number of vSplits: " + vSplits.length); } catch (ClassNotFoundException e) { e.printStackTrace(); } // Create new splits by computing the cartesian product of // all blocks from U with all blocks from V CompositeInputSplit[] resultSplits = new CompositeInputSplit[uSplits.length * vSplits.length]; int i = 0; // Splits are read in in alphabetical name order, therefore we can merge them together directly for (FileSplit uSplit : uSplits) { for (FileSplit vSplit : vSplits) { resultSplits[i] = new CompositeInputSplit(3); resultSplits[i].add(mSplits[i]); resultSplits[i].add(uSplit); resultSplits[i].add(vSplit); i++; } } return resultSplits; }
private void constituteTopic(int _topicid) { try { this.topic = bm.loadTopicWithCommentsByTopicId(_topicid); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } User u = new User(); try { u = um.loadUserByid(this.topic.getAuther()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } this.topic.setUser(u); for (Comment comm : this.topic.getComments()) { User cu = new User(); try { cu = um.loadUserByid(comm.getAuther()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } comm.setUser(cu); System.out.println("cu---" + cu.toString()); System.out.println("Comm---" + comm.toString()); System.out.println("Commuser---" + comm.getUser().toString()); } }
@Override public void init() throws ServletException { super.init(); IdeaWxConfig.initConfig("ideawx.properties"); // 初始化消息验证模块需要的TokenService String tokenServiceDef = IdeaWxConfig.get("ideawx.event.token.service", null); if (tokenServiceDef != null && tokenServiceDef.trim().length() > 0) { try { Class tokenServiceDefClazz = Class.forName(tokenServiceDef); eventTokenService = (EventTokenService) (tokenServiceDefClazz.newInstance()); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_TOKEN_SERVICE_NOT_FOUND, "Event Token Service not found.", e); } catch (InstantiationException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_TOKEN_SERVICE_INIT_ERROR, "Event Token Service initial error.", e); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_TOKEN_SERVICE_INIT_ERROR, "Event Token Service initial error.", e); } } else { eventTokenService = new ConfigEventTokenService(); } // 初始化EventReceiver String eventReceiverDef = IdeaWxConfig.get("ideawx.event.receiver", null); if (eventReceiverDef != null && eventReceiverDef.trim().length() > 0) { try { Class eventReceiverDefClazz = Class.forName(eventReceiverDef); eventReceiver = (EventReceiver) (eventReceiverDefClazz.newInstance()); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_RECEIVER_NOT_FOUND, "Event Token Service not found.", e); } catch (InstantiationException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_RECEIVER_NOT_FOUND, "Event Token Service initial error.", e); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IdeaWxException( IdeaWxExceptionCode.WX_EVENT_RECEIVER_NOT_FOUND, "Event Token Service initial error.", e); } } }
/** * 解析数据JSON * * @param strResult * @return */ public static ArrayList<NormalTableFinalModel> parseJson( String strResult, ArrayList<NormalTableModel> list_info) { ArrayList<NormalTableModel> list_model = null; ArrayList<NormalTableFinalModel> list_final_model = null; NormalTableFinalModel model = null; try { JSONObject jsonObject = new JSONObject(strResult); JSONArray jsonArray = jsonObject.getJSONArray("data"); list_final_model = new ArrayList<>(); if (!jsonArray.toString().equals("[]")) { for (int i = jsonArray.length() - 1; i >= 0; i--) { JSONObject object = jsonArray.getJSONObject(i); list_model = new ArrayList<>(); try { list_model = deepCopy(list_info); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } for (int j = 0; j < list_model.size(); j++) { list_model.get(j).setMiddleText(object.getString(list_model.get(j).getName())); } model = new NormalTableFinalModel(); model.setIsEmpty("no"); model.setModel_name(jsonObject.getString("model_name")); model.setId(jsonArray.getJSONObject(i).getString("id")); model.setList_model(list_model); list_final_model.add(model); } } else { model = new NormalTableFinalModel(); model.setIsEmpty("yes"); model.setModel_name(jsonObject.getString("model_name")); list_model = new ArrayList<>(); try { list_model = deepCopy(list_info); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } model.setList_model(list_model); list_final_model.add(model); } } catch (Exception e) { L.d("yy", "NormalTableFinalModel Parse Error"); e.printStackTrace(); } return list_final_model; }
private HashMap<String, String> getLoginInfo( String url, String db, String userName, String password) throws SQLException { Connection con = null; String driver = "com.mysql.jdbc.Driver"; HashMap<String, String> info = new HashMap<String, String>(); try { Class.forName(driver); con = DriverManager.getConnection(url + db, userName, password); String selectStatement = "SELECT userId,userName FROM Users"; Statement st = con.createStatement(); ResultSet linksRecords = st.executeQuery(selectStatement); while (linksRecords.next()) { info.put(linksRecords.getString("userId"), linksRecords.getString("userName")); } linksRecords.close(); } catch (SQLException s) { // System.out.println("SQL statement is not executed!\n"+s.getMessage()); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return info; }
@SuppressWarnings({"rawtypes"}) private Set<Class> getTableBeans() throws IOException, URISyntaxException { ClassLoader loader = getClass().getClassLoader(); ClassPath cp; Set<ClassInfo> rss = null; try { cp = ClassPath.from(loader); rss = cp.getAllClasses(); } catch (IOException e1) { e1.printStackTrace(); } Set<Class> results = Sets.newHashSet(); for (ClassInfo info : rss) { String className = info.getName(); if (exclude(className)) continue; Class clazz; try { clazz = loader.loadClass(className); if (Storable.class.isAssignableFrom(clazz) && clazz != Storable.class) { results.add(clazz); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } return results; }
@SuppressWarnings("rawtypes") public static Class loadPluginClassByName(String clazzName) { PluginDescriptor pluginDescriptor = getPluginDescriptorByClassName(clazzName); if (pluginDescriptor != null) { ensurePluginInited(pluginDescriptor); DexClassLoader pluginClassLoader = pluginDescriptor.getPluginClassLoader(); try { Class pluginClazz = ((ClassLoader) pluginClassLoader).loadClass(clazzName); LogUtil.d("loadPluginClass Success for clazzName ", clazzName); return pluginClazz; } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (java.lang.IllegalAccessError illegalAccessError) { illegalAccessError.printStackTrace(); throw new IllegalAccessError( "出现这个异常最大的可能是插件dex和" + "宿主dex包含了相同的class导致冲突, " + "请检查插件的编译脚本,确保排除了所有公共依赖库的jar"); } } LogUtil.e("loadPluginClass Fail for clazzName ", clazzName); return null; }
public Object(Room r, int x, int y, Sprite sprite) { this.r = r; this.x = x; this.y = y; this.sprite = sprite; // don't use reflection if it has been done for this class before if (r.collision_methods.containsKey(this.getClass())) collision_methods = r.collision_methods.get(this.getClass()); // use reflection to detect collision methods for the first time with this class else { for (Method method : this.getClass().getMethods()) { if (method.getName().startsWith("collision_")) { String[] method_name = method.getName().split("_"); try { // try to get the target class for the detected collision method // example: collision_Player -> `Player` collision_methods.put( method, Class.forName( this.getClass().getPackage().toString().split(" ")[1] + "." + method_name[1])); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } // save methods list in a reusable place r.collision_methods.put(this.getClass(), collision_methods); } }
public static int getResourseIdByName(String packageName, String className, String name) { Class r = null; int id = 0; try { r = Class.forName(packageName + ".R"); Class[] classes = r.getClasses(); Class desireClass = null; for (int i = 0; i < classes.length; i++) { if (classes[i].getName().split("\\$")[1].equals(className)) { desireClass = classes[i]; break; } } if (desireClass != null) id = desireClass.getField(name).getInt(desireClass); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return id; }
/** * Helper function for reflective invocation. * * @param cl class loader * @param className class name * @param methodName method name * @param argTypes arg types (optional) * @param args arguments * @return return value from invoked method */ public static Object invoke(ClassLoader cl, String className, String methodName, Class[] argTypes, Object[] args) { Class c; try { c = Class.forName(className, true, cl); } catch (ClassNotFoundException e0) { System.err.println("Cannot load "+className); e0.printStackTrace(); return null; } Method m = getDeclaredMethod(c, methodName, argTypes); Object result; try { result = m.invoke(null, args); } catch (IllegalArgumentException e2) { System.err.println("Illegal argument exception"); e2.printStackTrace(); return null; } catch (IllegalAccessException e2) { System.err.println("Illegal access exception"); e2.printStackTrace(); return null; } catch (InvocationTargetException e2) { if (e2.getTargetException() instanceof RuntimeException) throw (RuntimeException) e2.getTargetException(); if (e2.getTargetException() instanceof Error) throw (Error) e2.getTargetException(); System.err.println("Unexpected exception thrown!"); e2.getTargetException().printStackTrace(); return null; } return result; }
/** * Creates the brain and launches if it is an agent. The brain class is given as a String. The * name argument is used to instantiate the name of the corresponding agent. If the gui flag is * true, a bean is created and associated to this agent. */ public void makeBrain(String className, String name, boolean gui, String behaviorFileName) { try { Class c; c = Utils.loadClass(className); myBrain = (Brain) c.newInstance(); myBrain.setBody(this); if (myBrain instanceof AbstractAgent) { String n = name; if (n == null) { n = getLabel(); } if (n == null) { n = getID(); } if (behaviorFileName != null) setBehaviorFileName(behaviorFileName); myBrain.init(); getStructure().getAgent().doLaunchAgent((AbstractAgent) myBrain, n, gui); } } catch (ClassNotFoundException ev) { System.err.println("Class not found :" + className + " " + ev); ev.printStackTrace(); } catch (InstantiationException e) { System.err.println("Can't instanciate ! " + className + " " + e); e.printStackTrace(); } catch (IllegalAccessException e) { System.err.println("illegal access! " + className + " " + e); e.printStackTrace(); } }
public static void testStreamTest(String sql) { String url = "jdbc:mysql://localhost:3306/toy?user=cc&password=chenchi"; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection connection; PreparedStatement preparedStatement; ResultSet resultSet; int counter = 0; try { connection = DriverManager.getConnection(url); preparedStatement = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); preparedStatement.setFetchSize(Integer.MIN_VALUE); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { System.out.println(resultSet.getString(2)); System.out.println(++counter); } } catch (Exception e) { e.printStackTrace(); } finally { System.out.println("finally"); // 忽略 } }
// Load a neural network from memory public NeuralNetwork loadGenome() { // Read from disk using FileInputStream FileInputStream f_in = null; try { f_in = new FileInputStream("./memory/mydriver.mem"); } catch (FileNotFoundException e) { e.printStackTrace(); } // Read object using ObjectInputStream ObjectInputStream obj_in = null; try { obj_in = new ObjectInputStream(f_in); } catch (IOException e) { e.printStackTrace(); } // Read an object try { return (NeuralNetwork) obj_in.readObject(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return null; }
public static void main(String[] args) { Connection conn = null; Statement stm = null; ResultSet rs = null; String url = "jdbc:mysql://localhost:3308/tests"; String user = "******"; String pwd = "123456"; String sql = "select * from student where id<20;"; // 加载驱动 try { Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(url, user, pwd); stm = conn.createStatement(); rs = stm.executeQuery(sql); // 没有移动前的数据 System.out.println("未移动前的数据"); while (rs.next()) { System.out.println(rs.getInt("id") + "\t" + rs.getString("name") + "\t" + rs.getInt("age")); } // 移动最前边 rs.beforeFirst(); System.out.println("移到最前的数据"); while (rs.next()) { System.out.println(rs.getInt("id") + "\t" + rs.getString("name") + "\t" + rs.getInt("age")); } } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
// Yhteyden avaaminen public boolean avaaYhteys() { // Vaihe 1: tietokanta-ajurin lataaminen try { Class.forName(AJURI); } catch (ClassNotFoundException e) { System.out.println("Ajurin lataaminen ei onnistunut. Lopetetaan ohjelman suoritus."); e.printStackTrace(); return false; } // Vaihe 2: yhteyden ottaminen tietokantaan con = null; try { con = DriverManager.getConnection( PROTOKOLLA + "//" + PALVELIN + ":" + PORTTI + "/" + TIETOKANTA, KAYTTAJA, SALASANA); stmt = con.createStatement(); // Toiminta mahdollisessa virhetilanteessa } catch (SQLException e) { System.out.println("Yhteyden avaamisessa tapahtui seuraava virhe: " + e.getMessage()); e.printStackTrace(); return false; } return true; }
private List<LinkCandidate> getLinksCandidates( String url, String db, String userName, String password) throws SQLException { // JDBCConnectionPool x=new SimpleJDBCConnectionPool("com.mysql.jdbc.Driver", // "jdbc:mysql://localhost:3306/", "hgf", "xxxxx"); List<LinkCandidate> infoList = new ArrayList<LinkCandidate>(); Connection con = null; String driver = "com.mysql.jdbc.Driver"; try { Class.forName(driver); con = DriverManager.getConnection(url + db, userName, password); String selectStatement = "SELECT * FROM Links"; Statement st = con.createStatement(); ResultSet linksRecords = st.executeQuery(selectStatement); while (linksRecords.next()) { // infoList.add(new // LinkCandidate(linksRecords.getString("sourceURI"),linksRecords.getString("destinationURI"), linksRecords.getString("relationMapping"))); } linksRecords.close(); } catch (SQLException s) { } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return infoList; }
void storeLatestWorkbenchGraph() { Graph latestWorkbenchGraph = workbench.getGraph(); if (latestWorkbenchGraph.getNumNodes() == 0) { return; } SearchParams searchParams = algorithmRunner.getParams(); try { Graph graph = new MarshalledObject<Graph>(latestWorkbenchGraph).get(); if (graph == null) { throw new NullPointerException("Null graph"); } if (searchParams != null) { searchParams.setSourceGraph(graph); } } catch (IOException e) { e.printStackTrace(); if (searchParams != null) { searchParams.setSourceGraph(null); } } catch (ClassNotFoundException e) { if (searchParams != null) { searchParams.setSourceGraph(null); } e.printStackTrace(); } }
public String ConectarBD(String... strings) { String ls_usuario = "COMERCIAL"; String ls_clave = "COMERCIAL"; String ls_sql = "select pvp from INV_ARTICULO where cod_barras ='" + strings[1] + "'"; /* String ls_sql = "select pvp from INV_ARTICULO where cod_barras ='9788431681111'";*/ try { Class.forName("oracle.jdbc.OracleDriver"); conexion = DriverManager.getConnection(strings[0], ls_usuario, ls_clave); Statement estado = conexion.createStatement(); resultado = (ResultSet) estado.executeQuery(ls_sql); while (resultado.next()) { ls_precio = "Precio: " + resultado.getString(1); } System.out.println("Conexion realizada " + ls_precio); resultado.close(); estado.close(); conexion.close(); } catch (ClassNotFoundException e) { /*Toast.makeText(getApplicationContext(), "ERROR:" + e.getMessage(), Toast.LENGTH_SHORT).show();*/ e.printStackTrace(); } catch (SQLException e) { /*Toast.makeText(getApplicationContext(), "ERROR: " + e.getMessage(), Toast.LENGTH_SHORT).show();*/ e.printStackTrace(); } return ls_precio; }
@Override protected ResultSet doInBackground(String... strings) { String ls_usuario = "pavel"; String ls_clave = "pavelito"; String ls_sql = "insert into punto (color,cantidad) values('" + strings[1] + "',1)"; try { Class.forName("com.mysql.jdbc.Driver"); conexionMysql = DriverManager.getConnection(strings[0], ls_usuario, ls_clave); Statement estado = conexionMysql.createStatement(); estado.execute(ls_sql); System.out.println("Conexion realizada"); conexionMysql.commit(); conexionMysql.close(); } catch (ClassNotFoundException e) { /*Toast.makeText(getApplicationContext(), "ERROR:" + e.getMessage(), Toast.LENGTH_SHORT).show();*/ e.printStackTrace(); } catch (SQLException e) { /*Toast.makeText(getApplicationContext(), "ERROR: " + e.getMessage(), Toast.LENGTH_SHORT).show();*/ e.printStackTrace(); } return null; }
public static void connectDatabase() { try { Class.forName("com.mysql.jdbc.Driver"); String databaseURL = "jdbc:mysql://76.219.184.137:3306/PVPWorld"; // Statement stmnt; databaseConnection = DriverManager.getConnection(databaseURL, "PVPWorldServer", "WarePhant8"); // stmnt = con.createStatement(); // stmnt.executeUpdate("CREATE TABLE myTable(test_id int,test_val char(15) not null)"); // stmnt.executeUpdate("INSERT INTO myTable(test_id, test_val) VALUES(1,'One')"); // stmnt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); // ResultSet rs = stmnt.executeQuery("SELECT * from myTable ORDER BY test_id"); // System.out.println("Display all results:"); // while(rs.next()){ // int theInt= rs.getInt("test_id"); // String str = rs.getString("test_val"); // System.out.println("\ttest_id= " + theInt // + "\tstr = " + str); // }//end while loop } catch (ClassNotFoundException e1) { e1.printStackTrace(); System.exit(1); } catch (SQLException e) { e.printStackTrace(); System.exit(1); } }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id = Integer.valueOf(request.getParameter("id")); Connection conexao = null; try { conexao = AbstractConnectionFactory.getConexao(); OrcamentoDao orcamentoDao = new OrcamentoDao(conexao); orcamentoDao.excluirOrcamento(id); write(response, "Orcamento excluido com sucesso"); } catch (ClassNotFoundException e) { e.printStackTrace(); write(response, "ERRO codigo CNFE10 " + e.getMessage()); } catch (SQLException e) { e.printStackTrace(); write(response, "ERRO codigo SQLE10 " + e.getMessage()); } finally { try { conexao.close(); } catch (SQLException e) { e.printStackTrace(); write(response, "ERRO codigo SQLE10 " + e.getMessage()); } } }
static void testReflectionTest3() { try { String imei = taintedString(); Class c = Class.forName("de.ecspride.ReflectiveClass"); Object o = c.newInstance(); Method m = c.getMethod("setIme" + "i", String.class); m.invoke(o, imei); Method m2 = c.getMethod("getImei"); String s = (String) m2.invoke(o); assert (getTaint(s) != 0); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/* * recovery a class from path's file */ @SuppressWarnings("finally") public Object readSerializableData(String path) { Object yyc = null; try { FileInputStream fis = new FileInputStream(path); ObjectInputStream ois = new ObjectInputStream(fis); yyc = (Object) ois.readObject(); ois.close(); return yyc; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (StreamCorruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { return yyc; } }
{ try { Class.forName(JDBC_DRIVER); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
/** * 根据插件中的classId加载一个插件中的class * * @param clazzId * @return */ @SuppressWarnings("rawtypes") public static Class loadPluginFragmentClassById(String clazzId) { PluginDescriptor pluginDescriptor = getPluginDescriptorByFragmenetId(clazzId); if (pluginDescriptor != null) { ensurePluginInited(pluginDescriptor); DexClassLoader pluginClassLoader = pluginDescriptor.getPluginClassLoader(); String clazzName = pluginDescriptor.getPluginClassNameById(clazzId); if (clazzName != null) { try { Class pluginClazz = ((ClassLoader) pluginClassLoader).loadClass(clazzName); LogUtil.d("loadPluginClass for clazzId", clazzId, "clazzName", clazzName, "success"); return pluginClazz; } catch (ClassNotFoundException e) { e.printStackTrace(); } } } LogUtil.e("loadPluginClass for clazzId", clazzId, "fail"); return null; }
static { try { Class.forName("com.inferneon.core.Instances"); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
private static void callPluginApplicationOnCreate(PluginDescriptor pluginDescriptor) { Application application = null; if (pluginDescriptor.getPluginApplication() == null && pluginDescriptor.getPluginClassLoader() != null) { try { LogUtil.d("创建插件Application", pluginDescriptor.getApplicationName()); application = Instrumentation.newApplication( pluginDescriptor .getPluginClassLoader() .loadClass(pluginDescriptor.getApplicationName()), pluginDescriptor.getPluginContext()); pluginDescriptor.setPluginApplication(application); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } // 安装ContentProvider PluginInjector.installContentProviders( sApplication, pluginDescriptor.getProviderInfos().values()); // 执行onCreate if (application != null) { application.onCreate(); } changeListener.onPluginStarted(pluginDescriptor.getPackageName()); }
public Card readCard(File filePath) { Card card = null; try { FileInputStream fis = new FileInputStream(filePath); ObjectInputStream ois = new ObjectInputStream(fis); card = (Card) ois.readObject(); System.out.println( "Card " + card.getName() + " converted mana cost " + card.getConvertedManacost()); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return card; }