@@ -0,0 +1,3004 @@
+package com.android.lexikon.utils;%0A%0Aimport android.content.Context;%0Aimport android.content.res.AssetManager;%0Aimport android.util.Log;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0A%0A/**%0A * Created by layer on 13/8/2558.%0A */%0Apublic class AssetUtil %7B%0A%0A    public static File copyAssets(Context context,String fileName) %7B%0A        AssetManager assetManager = context.getAssets();%0A        File outFile = null;%0A        InputStream in = null;%0A        OutputStream out = null;%0A        try %7B%0A            in = assetManager.open(fileName);%0A            // copy file path%0A            outFile = new File(context.getExternalFilesDir(null), fileName);%0A            out = new FileOutputStream(outFile);%0A            copyFile(in, out);%0A        %7D catch (IOException e) %7B%0A            Log.e(%22tag%22, %22Failed to copy asset file: %22 + fileName, e);%0A        %7D finally %7B%0A            if (in != null) %7B%0A                try %7B%0A                    in.close();%0A                %7D catch (IOException e) %7B%0A                    // NOOP%0A                %7D%0A            %7D%0A            if (out != null) %7B%0A                try %7B%0A                    out.close();%0A%0A                %7D catch (IOException e) %7B%0A                    // NOOP%0A                %7D%0A            %7D%0A%0A        %7D%0A        return outFile;%0A    %7D%0A%0A        public static File copyAssets(Context context,String fileName,File outFile) %7B%0A        AssetManager assetManager = context.getAssets();%0A        InputStream in = null;%0A        OutputStream out = null;%0A        try %7B%0A            in = assetManager.open(fileName);%0A            out = new FileOutputStream(outFile);%0A            copyFile(in, out);%0A        %7D catch (IOException e) %7B%0A            Log.e(%22tag%22, %22Failed to copy asset file: %22 + fileName, e);%0A        %7D finally %7B%0A            if (in != null) %7B%0A                try %7B%0A                    in.close();%0A                %7D catch (IOException e) %7B%0A                    // NOOP%0A                %7D%0A            %7D%0A            if (out != null) %7B%0A                try %7B%0A                    out.close();%0A%0A                %7D catch (IOException e) %7B%0A                    // NOOP%0A                %7D%0A            %7D%0A%0A        %7D%0A        return outFile;%0A    %7D%0A%0A    private static void copyFile(InputStream in, OutputStream out) throws IOException %7B%0A        byte%5B%5D buffer = new byte%5B1024%5D;%0A        int read;%0A        while ((read = in.read(buffer)) != -1) %7B%0A            out.write(buffer, 0, read);%0A        %7D%0A    %7D%0A%0A    public static String loadJSONFromAsset(Context context, String filename) %7B%0A        String json = null;%0A        try %7B%0A%0A            InputStream is = context.getAssets().open(filename);%0A%0A            int size = is.available();%0A%0A            byte%5B%5D buffer = new byte%5Bsize%5D;%0A%0A            is.read(buffer);%0A%0A            is.close();%0A%0A            json = new String(buffer, %22UTF-8%22);%0A%0A%0A        %7D catch (IOException ex) %7B%0A            ex.printStackTrace();%0A            return null;%0A        %7D%0A        return json;%0A%0A    %7D%0A%7D%0A

Add AssetUtil