小知识点

三元运算符是一个整体

 -128 ~ 128 Inter.valueOf直接返回

 

 

 

 @test可以直接运行需要测试的方法(无需放到main中)

public class FileCreate {
    public static void main(String[] args) {

    }
    @Test
    public void create01() {
        String filePath = "e:\\news1.txt";
        File file = new File(filePath);

        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
View Code

 

 @Nullable 可以使这个字段为空(从而不报错)

 获得 当前时间str

 Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date)

 

posted @ 2022-04-28 09:44  磕伴  阅读(24)  评论(0)    收藏  举报