cancel
Showing results for 
Search instead for 
Did you mean: 

IWDResource getFileExtension returns null for "rar" & "msg" files

former_member182374
Active Contributor
0 Kudos

Hi all,

I'm using the fileUpload UI element which is bound to IWDResource type.

When I run:

String fileExtension = resource.getResourceType().getFileExtension();

I get null for the fileExtension if the files types are "rar" or "msg" (for other filetypes there is no problem).

A simple workaround is to use:

if ((fileExtension == null) || (fileExtension.length() == 0)) {
	String resourceName = resource.getResourceName(); 
	fileExtension = resourceName.substring(resourceName.lastIndexOf(".")+1, resourceName.length());
}

Is this a known behaviour of the "getFileExtension" method?

J2EE/WD version is 7.00.20

Omri

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185086
Active Contributor
0 Kudos

Hi

Try this

public static String getExtension(File f) {
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');
 
        if (f.isDirectory())
        	ext = null;
        else if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }

BR

Satish Kumar

former_member182374
Active Contributor
0 Kudos

Hi Satish,

Your code will work however I want to use the standard WD api...

Omri