Example usage for org.apache.commons.io ExtendedIOUtils DEFAULT_BUFFER_SIZE_VALUE

List of usage examples for org.apache.commons.io ExtendedIOUtils DEFAULT_BUFFER_SIZE_VALUE

Introduction

In this page you can find the example usage for org.apache.commons.io ExtendedIOUtils DEFAULT_BUFFER_SIZE_VALUE.

Prototype

int DEFAULT_BUFFER_SIZE_VALUE

To view the source code for org.apache.commons.io ExtendedIOUtils DEFAULT_BUFFER_SIZE_VALUE.

Click Source Link

Usage

From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java

protected void extractConfigFiles(File confDir, String resPrefix, Collection<String> names) {
    if (ConfigUtils.verifyFolderProperty(ConfigUtils.CONF_DIR_NAME, confDir)) {
        logger.info("extractConfigFiles(" + resPrefix + ") - created " + ExtendedFileUtils.toString(confDir));
    }//from  w ww  .  j av a2s .  co  m

    ClassLoader cl = ExtendedClassUtils.getDefaultClassLoader(getClass());
    for (String fileName : names) {
        File targetFile = new File(confDir, fileName);
        if (targetFile.exists()) {
            logger.info("extractConfigFiles(" + fileName + ")[" + resPrefix + "] skip - already exists: "
                    + ExtendedFileUtils.toString(targetFile));
            continue;
        }

        try {
            long copyLength = extractConfigFile(cl.getResourceAsStream(resPrefix + "/" + fileName), targetFile,
                    getWorkBuf(ExtendedIOUtils.DEFAULT_BUFFER_SIZE_VALUE));
            if (copyLength <= 0L) {
                throw new StreamCorruptedException("Bad copy count: " + copyLength);
            }

            logger.info("extractConfigFiles(" + resPrefix + ")[" + fileName + "] " + copyLength + " bytes: "
                    + ExtendedFileUtils.toString(targetFile));
        } catch (IOException e) {
            RuntimeException thrown = new RuntimeException(
                    "extractConfigFiles(" + resPrefix + ")[" + fileName + "]" + " failed ("
                            + e.getClass().getSimpleName() + ")" + " to extract contents: " + e.getMessage(),
                    e);
            logger.warn(thrown.getMessage(), e);
            throw thrown;
        }
    }
}