org.civis.blockchain.ssm.client.Utils.FileUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ssm-sdk-client Show documentation
Show all versions of ssm-sdk-client Show documentation
A SDK HTTP Client implementation to interact with signing state machines chaincode developped for Hyperleger Fabric.
The newest version!
package org.civis.blockchain.ssm.client.Utils;
import com.google.common.io.Resources;
import retrofit2.http.Url;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
public class FileUtils {
public static final String FILE = "file:";
public static File getFile(String filename) throws MalformedURLException {
URL url = getUrl(filename);
return new File(url.getFile());
}
public static URL getUrl(String filename) throws MalformedURLException {
if(filename.startsWith(FILE)) {
return new URL(filename);
}
return Resources.getResource(filename);
}
public static Reader getReader(String filename) throws IOException {
URL url = getUrl(filename);
return new InputStreamReader(url.openStream());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy