totalcross icon indicating copy to clipboard operation
totalcross copied to clipboard

Faster way to get file extensions

Open Iaggoq opened this issue 4 years ago • 0 comments

Issue Title

I would like to have a faster way to get file extensions

Describe the bug

Its too slow to get the files extensions.

To Reproduce

    private String getImageExtension(String path) {
        String[] extensoes = {".jpg", ".png", ".bmp", ".jpeg", ".gif",
                ".JPG", ".PNG", ".BMP", ".JPEG", ".GIF"};
        byte[] xml = null;
        for (int i = 0; i < extensoes.length; i++) {
            xml = Vm.getFile(path + extensoes[i]);

            if (xml != null) {
                return path + extensoes[i];
            }
        }

        return path;
    }

Additional context

Using this code its taking too long i would like to know if there is a better way.

Iaggoq avatar Nov 09 '20 14:11 Iaggoq