1

When right clicking on the particular file and select Properties in Windows, I get the following view:

enter image description here

How can I access those properties (Name, Value, Type) using Java as shown in the picture above?

I have tried BasicFileAttributes and UserDefinedFileAttributeView with no luck. It seems I can't access those attributes. Anyone has any idea on how to accomplish this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125

1 Answers1

0

It depends on really what these attributes are. I'm guessing they are in an NTFS ADS. Try something like the following:

import java.nio.file.Path;
import java.nio.file.Files;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.file.attribute.*;

public class NtfsStream {
    public static void main(String[] args) throws Exception {
        Path file = Path.of(args[0]);
        UserDefinedFileAttributeView view = Files.getFileAttributeView(file, UserDefinedFileAttributeView.class);
        for (String name : view.list()) {
            ByteBuffer buf = ByteBuffer.allocate(view.size(name));
            view.read(name, buf);
            buf.flip();
            String value = Charset.defaultCharset().decode(buf).toString();
            System.out.printf("%s=%s%n", name, value);
        }
    }
}
g00se
  • 3,207
  • 2
  • 5
  • 9
  • I have tried that as already pointed out in the question and sadly it doesnt work... – MaVRoSCy Aug 21 '23 at 11:15
  • Using UserDefinedFileAttributeView , i am able to add an attribute and read it, but cannot read the rest of the attributes already present in the file as shown in the picture – MaVRoSCy Aug 21 '23 at 11:17
  • Well I *did* say it depends on the type of attributes ;) What type of file is that .ac file? – g00se Aug 21 '23 at 11:25
  • https://documentation.caseware.com/2022/WorkingPapers/en/Content/Engagements/File-Preparation/Create-Files/File-Extension-Index.htm – MaVRoSCy Aug 21 '23 at 11:30
  • OK. Now it might help if you can get that link working that you posted – g00se Aug 21 '23 at 11:33
  • this should work https://easyupload.io/59bfvt – MaVRoSCy Aug 21 '23 at 12:48
  • Downloaded fine this one – Oleg Cherednik Aug 21 '23 at 13:22
  • I think what you're looking at there might be an Explorer tab provided essentially by Caseware, giving you a view of info contained in one of its proprietary format files. Crude reverse engineering provided by `strings -e l -t x MetaDataExample2010.ac` – g00se Aug 21 '23 at 13:44