use of com.alibaba.alink.common.io.filesystem.LocalFileSystem in project Alink by alibaba.
the class Chap03 method c_1_1.
static void c_1_1() throws Exception {
LocalFileSystem local = new LocalFileSystem();
System.out.println(local.getHomeDirectory());
System.out.println(local.getKind());
if (!local.exists(LOCAL_DIR)) {
local.mkdirs(LOCAL_DIR);
}
for (FileStatus status : local.listStatus(LOCAL_DIR)) {
System.out.println(status.getPath().toUri() + " \t" + status.getLen() + " \t" + new Date(status.getModificationTime()));
}
String path = LOCAL_DIR + "hello.txt";
OutputStream outputStream = local.create(path, WriteMode.OVERWRITE);
outputStream.write("Hello Alink!".getBytes());
outputStream.close();
FileStatus status = local.getFileStatus(path);
System.out.println(status);
System.out.println(status.getLen());
System.out.println(new Date(status.getModificationTime()));
InputStream inputStream = local.open(path);
String readString = IOUtils.toString(inputStream);
System.out.println(readString);
}
Aggregations