Delete a File's User-Defined Attribute - Java File Path IO

Java examples for File Path IO:File Attribute

Introduction

The following shows how to delete the attribute defined earlier:

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 {//from www .  j a va  2 s .  c  o m
      udfav.delete("file.description");
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials