com.nepxion.discovery.common.property.DiscoveryContent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-common Show documentation
Show all versions of discovery-common Show documentation
Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent
package com.nepxion.discovery.common.property;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import com.nepxion.discovery.common.util.IOUtil;
public class DiscoveryContent {
private String content;
public DiscoveryContent(String path, String encoding) throws IOException {
InputStream inputStream = null;
try {
inputStream = IOUtil.getInputStream(path);
this.content = IOUtils.toString(inputStream, encoding);
} finally {
if (inputStream != null) {
IOUtils.closeQuietly(inputStream);
}
}
}
public DiscoveryContent(File file, String encoding) throws IOException {
this.content = FileUtils.readFileToString(file, encoding);
}
public DiscoveryContent(StringBuilder stringBuilder) throws IOException {
this.content = stringBuilder.toString();
}
public String getContent() {
return content;
}
}