Java Basic File Attributes
Windows & Linux
0:00 - введение
0:10- запуск Java кода на eclipse
0:39- код и результат программы
1:14- ubuntu ОС Linux
2:45- демонстрация кода в Linux
2:55- вывод
КОД:
package test11;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.*;
public class Main {
public static void main(String[] args) throws IOException {
Path file = Paths.get("D:/123.txt");
BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);
if (attr.creationTime() != null) {
System.out.println("дата создания: " + attr.creationTime());
}
if (attr.lastAccessTime() != null) {
System.out.println("дата последнего обращения: " + attr.lastAccessTime());
}
if (attr.lastModifiedTime() != null) {
System.out.println("дата последнего изменения: " + attr.lastModifiedTime());
}
System.out.println("является папкой: " + attr.isDirectory());
System.out.println("прочее: " + attr.isOther());
System.out.println("обычный файл: " + attr.isRegularFile());
System.out.println("размер в байтах: " + attr.size());
System.out.println("Атрибуты файла в DOS");
try {
DosFileAttributes attr1 = Files.readAttributes(file, DosFileAttributes.class);
System.out.println("только для чтения: " + attr1.isReadOnly());
System.out.println("скрытый: " + attr1.isHidden());
System.out.println("архивный: " + attr1.isArchive());
System.out.println("системный: " + attr1.isSystem());
} catch (UnsupportedOperationException x) {
System.err.println("DOS file attributes not supported:" + x);
}
}
}
On this page of the site you can watch the video online Java Basic File Attributes with a duration of hours minute second in good quality, which was uploaded by the user Valentin Arkov 12 January 2022, share the link with friends and acquaintances, this video has already been watched 99 times on youtube and it was liked by 0 viewers. Enjoy your viewing!