kz.greetgo.msoffice.docx.InputSourceFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greetgo.msoffice Show documentation
Show all versions of greetgo.msoffice Show documentation
greetgo library to generate or parse MS Office files
package kz.greetgo.msoffice.docx;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class InputSourceFactory {
private InputSourceFactory() {}
public static InputSource createByFile(final File file) {
return new InputSource() {
@Override
public InputStream openInputStream() throws Exception {
return new FileInputStream(file);
}
};
}
public static InputSource createByResource(final Class> classs, final String name) {
return new InputSource() {
@Override
public InputStream openInputStream() throws Exception {
return classs.getResourceAsStream(name);
}
};
}
public static InputSource createByResource(final String name) {
return new InputSource() {
@Override
public InputStream openInputStream() throws Exception {
return Object.class.getResourceAsStream(name);
}
};
}
}