
com.clusterra.pmbok.pdf.application.ResourceHelper Maven / Gradle / Ivy
/*
* Copyright (c) 2015.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.clusterra.pmbok.pdf.application;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.Validate;
import org.springframework.core.io.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Denis Kuchugurov
* on 13/05/15 23:13.
*/
public abstract class ResourceHelper {
public static Map getContent(Map resources) {
Validate.notNull(resources, "resources is null");
Map result = new HashMap<>(resources.size());
for (Map.Entry entry : resources.entrySet()) {
try {
InputStream inputStream = entry.getValue().getInputStream();
byte[] content = IOUtils.toByteArray(inputStream);
result.put(entry.getKey(), content);
IOUtils.closeQuietly(inputStream);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy