package io.schinzel.basicutils.file;

import com.google.common.io.Resources;
import io.schinzel.basicutils.UTF8;
import io.schinzel.basicutils.str.Str;
import io.schinzel.basicutils.thrower.Thrower;

import java.io.IOException;
import java.net.URL;

/**
 * Purpose of this class is to read resource files
 * <p>
 * Created by Schinzel on 2018-01-13
 */
public class ResourceReader {


    public static String read(String fileName) {
        byte[] bytes = ResourceReader.readAsByteArrayInternal(fileName, false);
        return UTF8.getString(bytes);
    }


    public static Str readAsStr(String fileName) {
        String string = ResourceReader.read(fileName);
        return Str.create(string);
    }


    public static byte[] readAsByteArray(String fileName) {
        return ResourceReader.readAsByteArrayInternal(fileName, false);
    }


    static byte[] readAsByteArrayInternal(String fileName, boolean throwIOException) {
        Thrower.throwIfVarEmpty(fileName, "fileName");
        URL url = Resources.getResource(fileName);
        try {
            if (throwIOException) {
                throw new IOException();
            }
            return Resources.toByteArray(url);
        } catch (IOException e) {
            throw new RuntimeException("Error when reading resource file '" + fileName + "'. " + e.getMessage());
        }
    }


}

@@ -545,32 +545,70 @@
 bytes);%0A    %7D%0A%0A%0A
+    @SuppressWarnings(%22WeakerAccess%22)%0A
     public stati
@@ -736,24 +736,62 @@
 g);%0A    %7D%0A%0A%0A
+    @SuppressWarnings(%22WeakerAccess%22)%0A
     public s

Handle warnings