0

I notice that the File class has a property called folderType, but I cannot see anyway to get this String at run-time. Is there a way? Edit: perhaps it's not part of File.

When I rest my mouse over file in the fileIO.open

KiloJKilo
  • 465
  • 1
  • 6
  • 16

2 Answers2

0

There are many ways one of them is this MimetypesFileTypeMap().getContentType(file)

and i think fileio is object of class Win32ShellFolder2,this has a public function getFolderType() as mentioned here

so you can use it like this i feel

fileIO.open(file).getFolderType()
user1627167
  • 339
  • 1
  • 8
0

The object you have there is a Win32ShellFolder2, which is a subclass of ShellFolder, which is a subclass of java.io.File. ShellFolder defines a getter named getFolderType() which returns the folder type as a string.

So you could get the contents of the field like this:

file = fileChooser.getSelectedFile();
if (file instanceof ShellFolder) {
    ShellFolder sf = (ShellFolder)file;
    String folderType = sf.getFolderType();

ShellFolder and Win32ShellFolder2 are in the package sun.awt.shell. This package isn't part of the standard Java API, so it could change from one JVM to another or from version of the JVM to another. See With what should I replace sun.awt.shell.ShellFolder so I don't get compile warnings?.

Community
  • 1
  • 1
Kenster
  • 23,465
  • 21
  • 80
  • 106