zoukankan      html  css  js  c++  java
  • Code digest

        private void travelDir(String filepath) {
            String threadName = Thread.currentThread().toString();
            logger.info("TargetDir:" + threadName + "==>" + filepath);
            File dir = new File(filepath);
            logger.info("dir.exists():" + threadName + "==>" + dir.exists());
    
            if (dir.exists()) {
                logger.info("dir.isDirectory():" + threadName + "==>"
                    + dir.isDirectory());
                File[] files = dir.listFiles();
                for (File file : files) {
                    logger.info("file.getAbsolutePath():" + threadName + "==>"
                            + file.getAbsolutePath());
                }
            }
        }
    public class CalcutateTest {
        @Test
        public void testAdd() {
            Calcutate cal = new Calcutate();
            Class<Calcutate> c = Calcutate.class;// 获得class类
    
            try {
                Method method = c.getDeclaredMethod("add", new Class[] { int.class,
                        int.class });// 获得method.注意,这里不能使用getMethod方法,因为这个方法只能获取public修饰的方法..
                method.setAccessible(true);// 这个设置为true.可以无视java的封装..不设置这个也无法获取这个Method
                Object result = method.invoke(cal, new Object[] { 2, 10 });
                Assert.assertEquals("Must equals.",12, result);// 这里自动拆箱..
            } catch (Exception e) {
                e.printStackTrace();
            }
            
        }
    }
  • 相关阅读:
    7. 整数反转
    14. 最长公共前缀
    13. 罗马数字转整数
    从web解析到网络空间
    python实例:霍兰德人格分析雷达图
    从数据处理到人工智能
    Python第三方库的安装
    Python之os库的使用
    Python第三方库的安装
    Python程序设计思维
  • 原文地址:https://www.cnblogs.com/softidea/p/4741962.html
Copyright © 2011-2022 走看看