博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Code digest
阅读量:7105 次
发布时间:2019-06-28

本文共 1350 字,大约阅读时间需要 4 分钟。

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
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(); } }}

 

转载于:https://www.cnblogs.com/softidea/p/4741962.html

你可能感兴趣的文章
Airbnb: React Native 从选择到放弃
查看>>
Eclipse中Tomcat配置问题
查看>>
Linux下使用split按行数进行切割
查看>>
盘点2015年英特尔旧金山IDF峰会上的黑科技
查看>>
SQL性能优化
查看>>
U盘安装Ubuntu 16.04出现:Failed to load ldlinux.c32
查看>>
mysql中的主从复制slave-skip-errors参数使用方法
查看>>
Linux安装JIRA6.3.6以及安装破解汉化插件
查看>>
一个HTTP需要经过哪些步骤
查看>>
Finite State Transducers
查看>>
慧聪电子网战略升级 玩转电子产业供应链服务之道
查看>>
Javascript定时器(三)——setTimeout(func, 0)
查看>>
Git基础入门(七)Git撤销操作和远程仓库管理
查看>>
以毒攻毒?牛津大学研究人员用VR治愈被迫害妄想症
查看>>
巧用Powercfg命令 - 玩转Windows 7中的电源管理
查看>>
Java工具创建密钥库,用于Unity 3D打包、签名、发布
查看>>
《你不知道的JavaScript》整理(二)——this
查看>>
提升windows 2000的启动速度
查看>>
iftop工具
查看>>
java-第二章-华氏温度转摄氏温度
查看>>