How to get file properties via Java API
Accepted answer
1) Get the IShareable for the file.
Ex:
ResourceType resourceType = CommonUtil.getResourceType(path, monitor);
if (resourceType == null) {
// pick file as the default - doesn't exist
resourceType = ResourceType.FILE;
}
IShareable shareable = SharingManager.getInstance().findShareable(path, resourceType));
Ex:
ResourceType resourceType = CommonUtil.getResourceType(path, monitor);
if (resourceType == null) {
// pick file as the default - doesn't exist
resourceType = ResourceType.FILE;
}
IShareable shareable = SharingManager.getInstance().findShareable(path, resourceType));
2) Get the FileItemInfo.
Ex:
FileItemInfo info = ((Shareable) shareable).getFileItemInfo(monitor);
FileItemInfo has the following properties:
-line delimiter
-encoding
-executable
-content type
Comments
1 vote
Comments
David Lafreniere
FORUM MODERATOR / JAZZ DEVELOPER Apr 07 '20, 9:40 a.m.Geoff Alexander
Apr 07 '20, 10:09 a.m.