// Path: components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/exceptions/ScriptException.java
// public class ScriptException extends Exception {
// 
//     public ScriptException(String message) {
//         super(message);
//     }
// 
//     public ScriptException(Exception exception) {
//         super(exception);
//     }
// 
//     public ScriptException(String message, Exception exception) {
//         super(message, exception);
//     }
// }


import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jaggeryjs.scriptengine.exceptions.ScriptException;
import javax.activation.FileTypeMap;
import java.io.*;
import java.util.ArrayList;
import static java.lang.Math.min;
        if (!opened) {
            log.warn("You need to open the file for reading");
            return null;
        }
        if (!readable) {
            log.warn("File has not opened in a readable mode.");
            return null;
        }
        try {
            byte[] arr = new byte[(int) min(count, file.length())];
            file.readFully(arr);
            return new String(arr, "UTF-8");
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            throw new ScriptException(e);
        }
    }

    @Override
    public void write(String data) throws ScriptException {
        if (!opened) {
            log.warn("You need to open the file for writing");
            return;
        }
        if (!writable) {
            log.warn("File has not opened in a writable mode.");
            return;
        }
        try {
            file.writeBytes(data);
// Path: components/script-engine/org.jaggeryjs.scriptengine/src/main/java/org/jaggeryjs/scriptengine/exceptions/ScriptException.java
// public class ScriptException extends Exception {
// 
//     public ScriptException(String message) {
//         super(message);
//     }
// 
//     public ScriptException(Exception exception) {
//         super(exception);
//     }
// 
//     public ScriptException(String message, Exception exception) {
//         super(message, exception);
//     }
// }


// Path: components/hostobjects/org.jaggeryjs.hostobjects.file/src/main/java/org/jaggeryjs/hostobjects/file/JavaScriptFileImpl.java
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jaggeryjs.scriptengine.exceptions.ScriptException;
import javax.activation.FileTypeMap;
import java.io.*;
import java.util.ArrayList;
import static java.lang.Math.min;

        if (!opened) {
            log.warn("You need to open the file for reading");
            return null;
        }
        if (!readable) {
            log.warn("File has not opened in a readable mode.");
            return null;
        }
        try {
            byte[] arr = new byte[(int) min(count, file.length())];
            file.readFully(arr);
            return new String(arr, "UTF-8");
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            throw new ScriptException(e);
        }
    }

    @Override
    public void write(String data) throws ScriptException {
        if (!opened) {
            log.warn("You need to open the file for writing");
            return;
        }
        if (!writable) {
            log.warn("File has not opened in a writable mode.");
            return;
        }
        try {
            file.writeBytes(data);
        } catch (IOException e) {