Java Code Examples for org.codehaus.groovy.runtime.ResourceGroovyMethods#newReader()

The following examples show how to use org.codehaus.groovy.runtime.ResourceGroovyMethods#newReader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseJsonParser.java    From groovy with Apache License 2.0 6 votes vote down vote up
public Object parse(File file, String charset) {
    Reader reader = null;
    try {
        if (charset == null || charset.length() == 0) {
            reader = ResourceGroovyMethods.newReader(file);
        } else {
            reader = ResourceGroovyMethods.newReader(file, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process file: " + file.getPath(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 2
Source File: JsonSlurperClassic.java    From groovy with Apache License 2.0 6 votes vote down vote up
private Object parseFile(File file, String charset) {
    Reader reader = null;
    try {
        if (charset == null || charset.length() == 0) {
            reader = ResourceGroovyMethods.newReader(file);
        } else {
            reader = ResourceGroovyMethods.newReader(file, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process file: " + file.getPath(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 3
Source File: JsonSlurperClassic.java    From groovy with Apache License 2.0 6 votes vote down vote up
private Object parseURL(URL url, Map params) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 4
Source File: JsonSlurperClassic.java    From groovy with Apache License 2.0 6 votes vote down vote up
private Object parseURL(URL url, Map params, String charset) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url, charset);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 5
Source File: JsonSlurper.java    From groovy with Apache License 2.0 6 votes vote down vote up
private Object parseURL(URL url, Map params) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params);
        }
        return createParser().parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 6
Source File: JsonSlurper.java    From groovy with Apache License 2.0 6 votes vote down vote up
private Object parseURL(URL url, Map params, String charset) {
    Reader reader = null;
    try {
        if (params == null || params.isEmpty()) {
            reader = ResourceGroovyMethods.newReader(url, charset);
        } else {
            reader = ResourceGroovyMethods.newReader(url, params, charset);
        }
        return parse(reader);
    } catch (IOException ioe) {
        throw new JsonException("Unable to process url: " + url.toString(), ioe);
    } finally {
        if (reader != null) {
            DefaultGroovyMethodsSupport.closeWithWarning(reader);
        }
    }
}
 
Example 7
Source File: FileSystemResourceManager.java    From groovy with Apache License 2.0 4 votes vote down vote up
public Reader getReader(String resourceName) throws IOException {
    return ResourceGroovyMethods.newReader(new File(basedir + resourceName));
}