@Test
public void testDeleteFileOrDirectory() throws IOException {
final FileSystem fileSystem = this.fileSystem.get(configuration);
final Path path = new Path("D:\input\file.txt");
final Path path1 = new Path("/input/file");
fileSystem.copyFromLocalFile(path,path1);
}
-rw-r--r--
root
supergroup
2.32 KB
2021/12/7 下午7:11:03
3
128 MB
file
api之下载文件
@Test
public void testDeleteFileOrDirectory() throws IOException {
final FileSystem fileSystem = this.fileSystem.get(configuration);
final Path path = new Path("D:\input");
final Path path1 = new Path("/input/file");
//fileSystem.copyFromLocalFile(path,path1);
fileSystem.copyToLocalFile(path1,path);
}
api之创建目录
@Test
public void testDeleteFileOrDirectory() throws IOException {
final FileSystem fileSystem = this.fileSystem.get(configuration);
final Path path = new Path("D:\input");
final Path path1 = new Path("/input/mkdir.txt");
//fileSystem.copyFromLocalFile(path,path1);
//fileSystem.copyToLocalFile(path1,path);
fileSystem.mkdirs(path1);
}
drwxr-xr-x
root
supergroup
0 B
2021/12/7 下午7:21:53
0
0 B
mkdir.txt
api之删除目录
@Test
public void testDeleteFileOrDirectory() throws IOException {
final FileSystem fileSystem = this.fileSystem.get(configuration);
final Path path = new Path("D:\input");
final Path path1 = new Path("/input/mkdir.txt");
//fileSystem.copyFromLocalFile(path,path1);
//fileSystem.copyToLocalFile(path1,path);
fileSystem.delete(path1,true);
}
# true表示可以递归删除目录
# false只能删除空文件
api之重命名
@Test
public void testDeleteFileOrDirectory() throws IOException {
final FileSystem fileSystem = this.fileSystem.get(configuration);
final Path path = new Path("/input/mkdir.txt");
final Path path1 = new Path("/input/mkdir");
//fileSystem.copyFromLocalFile(path,path1);
//fileSystem.copyToLocalFile(path1,path);
//fileSystem.delete(path1,true);
fileSystem.rename(path,path1);
}