工作中使用到的代码或者脚本记录

从classpath路径中,获取文件

import org.springframework.core.io.ClassPathResource;
import org.apache.commons.io.FileUtils;

    @Test
    public void testfile() throws IOException {
        File file = new ClassPathResource("aaa/bbb.json").getFile();
        String jsonStr = FileUtils.readFileToString(file, Charset.defaultCharset());
    }

spring单元测试设置private属性

@Test
public void whenNonPublicMethod_thenReflectionTestUtilsInvokeMethod() {
    Employee employee = new Employee();
    ReflectionTestUtils.setField(employee, "id", 1);
    employee.setName("Smith, John");
  
    assertTrue(ReflectionTestUtils.invokeMethod(employee, "employeeToString")
      .equals("id: 1; name: Smith, John"));
}

发起HTTP请求

使用 retrofit
参考:https://www.baeldung.com/retrofit

获取注解

参考:https://www.cnblogs.com/wujf/p/9115329.html

计算对象大小

参考:https://www.jianshu.com/p/aaddf00a1d83
使用VisualVM dump内存,然后查看对象占用内存。
在这里插入图片描述

csv操作

https://mkyong.com/java/how-to-read-and-parse-csv-file-in-java/
https://www.baeldung.com/opencsv

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值