List User-Defined Attribute Names and Value Sizes - Java File Path IO

Java examples for File Path IO:File Attribute

Description

List User-Defined Attribute Names and Value Sizes

Demo Code

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.UserDefinedFileAttributeView;

public class Main {
  public static void main(String[] args) {
    Path path = Paths.get("C:/folder1/folder2/folder4", "test.txt");
    UserDefinedFileAttributeView udfav = Files.getFileAttributeView(path,
        UserDefinedFileAttributeView.class);

    try {/*www  . j av  a  2  s  . c  om*/
      for (String name : udfav.list()) {
        System.out.println(udfav.size(name) + "     " + name);
      }
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials