参考下面的这个文章,第一次测试File类
https://blog.csdn.net/ai_bao_zi/article/details/81015141
[ractest@stbm000020-vm1 test_package]$ cat fileTest.java
package test_package;
import java.io.*;
public class fileTest {
public static void main(String[] args){
String parent = "/tmp/aa";
String child = "/tmp/aa/bb/cc.txt";
File parent_file = new File(parent);
File child_file = new File(parent_file,child);
String path = child_file.getPath();
System.out.println(path);
}
}
[ractest@stbm000020-vm1 classes]$ /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/bin/java test_package.fileTest
/tmp/aa/tmp/aa/bb/cc.txt