/*
	Copyright 2015 Denis Prasetio
	
	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at
	
	http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

package com.dotosoft.dotoquiz.utils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class FileUtils {
	public static Path getPath(String rootFolder, String folder, String file) {
		Path returnPath = Paths.get(rootFolder, folder, file);
		return returnPath;
	}
	
	public static boolean moveToTrash(File fileToDelete)
    {
		com.sun.jna.platform.FileUtils fileUtils = com.sun.jna.platform.FileUtils.getInstance();
        if (fileUtils.hasTrash())
        {
            try
            {
                fileUtils.moveToTrash( new File[] { fileToDelete } );
                return true;

            } catch (IOException ioe)
            {
            }
        }

        return false;
    }
}

@@ -621,40 +621,196 @@
 .io.
-File;%0Aimport java.io.IOException
+BufferedInputStream;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.URL
 ;%0Aim
@@ -1478,10 +1478,788 @@
 ;%0A    %7D%0A
+%09%0A%09public static boolean downloadFileToLocal( String urlPath, String saveToFile, boolean isReplaced ) %7B%0A%09%09try %7B%0A%09%09%09File checkfileExist = new File(saveToFile);%0A%09%09%09if(checkfileExist.exists() && !isReplaced) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09URL url = new URL(urlPath);%0A%09%09%09InputStream in = new BufferedInputStream(url.openStream());%0A%09%09%09ByteArrayOutputStream out = new ByteArrayOutputStream();%0A%09%09%09byte%5B%5D buf = new byte%5B1024%5D;%0A%09%09%09int n = 0;%0A%09%09%09while (-1!=(n=in.read(buf)))%0A%09%09%09%7B%0A%09%09%09   out.write(buf, 0, n);%0A%09%09%09%7D%0A%09%09%09out.close();%0A%09%09%09in.close();%0A%09%09%09byte%5B%5D response = out.toByteArray();%0A%09%09%09%0A%09%09%09FileOutputStream fos = new FileOutputStream(saveToFile);%0A%09%09%09fos.write(response);%0A%09%09%09fos.close();%0A%09%09%09%0A%09%09%09return true;%0A%09%09%7D catch ( Exception ex ) %7B%0A%09%09%09ex.printStackTrace();%0A%09%09%7D%0A%09%09%0A%09%09return false;%0A%09%7D%0A
 %7D%0A

Fix dotoquiz common