本文整理汇总了Java中org.pentaho.di.core.vfs.KettleVFS.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java KettleVFS.getInputStream方法的具体用法?Java KettleVFS.getInputStream怎么用?Java KettleVFS.getInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.vfs.KettleVFS
的用法示例。
在下文中一共展示了KettleVFS.getInputStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImage
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public static Image getImage(Display display,String location)
{
// TODO: find other instances of getImage (plugin, steps) and transition them to new model through an laf manager
try
{
return new Image(display, KettleVFS.getInputStream(location));
}
catch(Exception e)
{
try
{
return new Image(display,ImageUtil.class.getClassLoader().getResourceAsStream(location));
}
catch(Exception npe)
{
throw new RuntimeException("Unable to load image with name ["+location+"]", e);
}
}
}
示例2: loadFile
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public void loadFile(String filename) throws Exception {
this.filename= filename;
this.file = KettleVFS.getFileObject(filename);
InputStream is=null;
try {
is = KettleVFS.getInputStream(getFile());
for (Object data : getYaml().loadAll(is)) {
documents.add(data);
this.useMap=(data instanceof Map);
}
this.documenti=documents.iterator();
}finally {
if(is!=null) is.close();
}
}
示例3: equalFileContents
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
/**
* Check whether 2 files have the same contents.
*
* @param file1 first file to compare
* @param file2 second file to compare
* @return true if files are equal, false if they are not
*
* @throws IOException upon IO problems
*/
protected boolean equalFileContents(FileObject file1, FileObject file2)
throws IOException
{
// Really read the contents and do comparisons
DataInputStream in1 = new DataInputStream(new BufferedInputStream(
KettleVFS.getInputStream(KettleVFS.getFilename(file1))));
DataInputStream in2 = new DataInputStream(new BufferedInputStream(
KettleVFS.getInputStream(KettleVFS.getFilename(file2))));
char ch1, ch2;
while ( in1.available() != 0 && in2.available() != 0 )
{
ch1 = (char)in1.readByte();
ch2 = (char)in2.readByte();
if ( ch1 != ch2 )
return false;
}
if ( in1.available() != in2.available() )
{
return false;
}
else
{
return true;
}
}
示例4: equalFileContents
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
/**
* Check whether 2 files have the same contents.
*
* @param file1 first file to compare
* @param file2 second file to compare
* @return true if files are equal, false if they are not
*
* @throws IOException upon IO problems
*/
protected boolean equalFileContents(FileObject file1, FileObject file2)
throws IOException
{
// Really read the contents and do comparisons
DataInputStream in1 = new DataInputStream(new BufferedInputStream(
KettleVFS.getInputStream(KettleVFS.getFilename(file1))));
DataInputStream in2 = new DataInputStream(new BufferedInputStream(
KettleVFS.getInputStream(KettleVFS.getFilename(file2))));
char ch1, ch2;
while ( in1.available() != 0 && in2.available() != 0 )
{
ch1 = (char)in1.readByte();
ch2 = (char)in2.readByte();
if ( ch1 != ch2 )
return false;
}
if ( in1.available() != in2.available() )
{
return false;
}
else
{
return true;
}
}
示例5: openNextFile
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private void openNextFile() throws KettleException
{
// Close the last file before opening the next...
if (data.xbi!=null)
{
logBasic(Messages.getString("XBaseInput.Log.FinishedReadingRecords")); //$NON-NLS-1$
data.xbi.close();
}
// Replace possible environment variables...
data.file_dbf = data.files.getFile(data.fileNr);
data.fileNr++;
try
{
data.xbi=new XBase(KettleVFS.getInputStream(data.file_dbf));
data.xbi.setDbfFile(data.file_dbf.getName().getURI());
if (!Const.isEmpty(meta.getCharactersetName())) {
data.xbi.getReader().setCharactersetName(meta.getCharactersetName());
}
data.xbi.open();
logBasic(Messages.getString("XBaseInput.Log.OpenedXBaseFile")+" : ["+data.xbi+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
data.fields = data.xbi.getFields();
// Add this to the result file names...
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, data.file_dbf, getTransMeta().getName(), getStepname());
resultFile.setComment(Messages.getString("XBaseInput.ResultFile.Comment"));
addResultFile(resultFile);
}
catch(Exception e)
{
logError(Messages.getString("XBaseInput.Log.Error.CouldNotOpenXBaseFile1")+data.file_dbf+Messages.getString("XBaseInput.Log.Error.CouldNotOpenXBaseFile2")+e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
throw new KettleException(e);
}
}
示例6: getRowNumber
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private void getRowNumber() throws KettleException
{
try
{
if (data.file.getType() == FileType.FILE)
{
data.fr = KettleVFS.getInputStream(data.file);
data.isr = new InputStreamReader(new BufferedInputStream(data.fr, BUFFER_SIZE_INPUT_STREAM));
int c = 0;
data.lineStringBuffer.setLength(0);
while (c >= 0)
{
c = data.isr.read();
if (c == data.separator)
{
// Move Row number pointer ahead
data.rownr ++;
}
}
}
if(log.isDetailed()) log.logDetailed(toString(),Messages.getString("GetFilesRowsCount.Log.RowsInFile", data.file.toString(), ""+data.rownr));
}
catch (Exception e)
{
throw new KettleException(e);
}
}
示例7: getImage
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private InputStream getImage(PluginInterface pluginInterface) throws KettlePluginException {
ClassLoader classLoader = registry.getClassLoader(pluginInterface);
InputStream result = classLoader.getResourceAsStream(pluginInterface.getImageFile());
if (result == null) {
result = classLoader.getResourceAsStream("/" + pluginInterface.getImageFile());
}
if (result == null) {
try {
result = KettleVFS.getInputStream(pluginInterface.getImageFile());
} catch(Exception e) {
//ignore
}
}
return result;
}
示例8: getResource
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private InputStream getResource(String location) {
InputStream result = getClass().getClassLoader().getResourceAsStream(location);
if (result == null) {
try {
result = KettleVFS.getInputStream(location);
} catch (KettleFileException e) {
e.printStackTrace();
}
}
return result;
}
示例9: getRowNumber
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private void getRowNumber() throws KettleException {
try {
if (data.file.getType() == FileType.FILE) {
data.fr = KettleVFS.getInputStream(data.file);
// Avoid method calls - see here:
// http://java.sun.com/developer/technicalArticles/Programming/PerfTuning/
byte buf[] = new byte[8192]; // BufferedaInputStream default buffer size
int n;
while ((n = data.fr.read(buf)) != -1) {
for (int i = 0; i < n; i++) {
if (buf[i] == data.separator) {
data.rownr++;
}
}
}
}
if (log.isDetailed()) logDetailed(BaseMessages.getString(PKG, "GetFilesRowsCount.Log.RowsInFile", data.file.toString(), "" + data.rownr));
} catch (Exception e) {
throw new KettleException(e);
} finally {
// Close inputstream - not used except for counting
if (data.fr != null) {
BaseStep.closeQuietly(data.fr);
data.fr = null;
}
}
}
示例10: getFields
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space)
throws KettleStepException
{
GZIPInputStream fis = null;
DataInputStream dis = null;
try
{
InputStream is = KettleVFS.getInputStream(space.environmentSubstitute(filename), space);
fis = new GZIPInputStream(is);
dis = new DataInputStream(fis);
RowMetaInterface add = new RowMeta(dis);
for (int i=0;i<add.size();i++)
{
add.getValueMeta(i).setOrigin(name);
}
r.mergeRowMeta(add);
}
catch(KettleFileException kfe)
{
throw new KettleStepException(BaseMessages.getString(PKG, "CubeInputMeta.Exception.UnableToReadMetaData"), kfe); //$NON-NLS-1$
}
catch(IOException e)
{
throw new KettleStepException(BaseMessages.getString(PKG, "CubeInputMeta.Exception.ErrorOpeningOrReadingCubeFile"), e); //$NON-NLS-1$
}
finally
{
try
{
if (fis!=null) fis.close();
if (dis!=null) dis.close();
}
catch(IOException ioe)
{
throw new KettleStepException(BaseMessages.getString(PKG, "CubeInputMeta.Exception.UnableToCloseCubeFile"), ioe); //$NON-NLS-1$
}
}
}
示例11: getBuffer
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private Object[] getBuffer() throws KettleValueException{
// Open all files at once and read one row from each file...
if (data.files.size() > 0 && ( data.dis.size() == 0 || data.fis.size() == 0 )){
if(log.isBasic())
logBasic("Opening " + data.files.size() + " tmp-files...");
try{
for (int f=0;f<data.files.size() && !isStopped();f++){
FileObject fileObject = (FileObject)data.files.get(f);
if (log.isDetailed())
logDetailed("Opening tmp-file: ["+fileObject.getName()+"]");
InputStream fi = KettleVFS.getInputStream(fileObject);
DataInputStream di;
data.fis.add(fi);
if (data.compressFiles){
GZIPInputStream gzfi = new GZIPInputStream(new BufferedInputStream(fi));
di = new DataInputStream(gzfi);
data.gzis.add(gzfi);
}else
di = new DataInputStream(new BufferedInputStream(fi, 50000));
data.dis.add(di);
// How long is the buffer?
int buffersize=data.bufferSizes.get(f);
if (log.isDetailed())
logDetailed("["+fileObject.getName()+"] expecting "+buffersize+" rows...");
if (buffersize>0){
Object[] row = (Object [])data.outputRowMeta.readData(di);
data.rowBuffer.add( row ); // new row from input stream
data.tempRows.add( new RowTempFile(row,f) );
}
}
}catch(Exception e){
logError("Error reading back tmp-files : "+e.toString());
logError(Const.getStackTracker(e));
}
}
Object[] retval = null;
if (data.files.size()==0){
if (data.getBufferIndex<data.buffer.size()){
retval=(Object[])data.buffer.get(data.getBufferIndex);
data.getBufferIndex++;
}
}else{
if (data.rowBuffer.size()>0){
if (log.isRowLevel()){
for (int i=0;i<data.rowBuffer.size() && !isStopped();i++){
logRowlevel("--BR#"+i+": "+data.outputRowMeta.getString((Object[])data.rowBuffer.get(i)));
}
}
retval = data.tempRows.remove(0).row;
}
}
return retval;
}
示例12: init
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public boolean init(StepMetaInterface smi, StepDataInterface sdi)
{
meta=(CubeInputMeta)smi;
data=(CubeInputData)sdi;
if (super.init(smi, sdi))
{
try
{
String filename=environmentSubstitute(meta.getFilename());
// Add filename to result filenames ?
if(meta.isAddResultFile())
{
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject(filename), getTransMeta().getName(), toString());
resultFile.setComment("File was read by a Cube Input step");
addResultFile(resultFile);
}
data.fis=KettleVFS.getInputStream(filename);
data.zip = new GZIPInputStream(data.fis);
data.dis = new DataInputStream(data.zip);
try
{
data.meta = new RowMeta(data.dis);
return true;
}
catch(KettleFileException kfe)
{
logError(Messages.getString("CubeInput.Log.UnableToReadMetadata")+kfe.getMessage()); //$NON-NLS-1$
return false;
}
}
catch(IOException e)
{
logError(Messages.getString("CubeInput.Log.ErrorReadingFromDataCube")+e.toString()); //$NON-NLS-1$
}
}
return false;
}
示例13: getFields
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public void getFields(RowMetaInterface r, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space)
throws KettleStepException
{
GZIPInputStream fis = null;
DataInputStream dis = null;
try
{
InputStream is = KettleVFS.getInputStream(space.environmentSubstitute(filename));
fis = new GZIPInputStream(is);
dis = new DataInputStream(fis);
RowMetaInterface add = new RowMeta(dis);
if (add==null) return;
for (int i=0;i<add.size();i++)
{
add.getValueMeta(i).setOrigin(name);
}
r.mergeRowMeta(add);
}
catch(KettleFileException kfe)
{
throw new KettleStepException(Messages.getString("CubeInputMeta.Exception.UnableToReadMetaData"), kfe); //$NON-NLS-1$
}
catch(IOException e)
{
throw new KettleStepException(Messages.getString("CubeInputMeta.Exception.ErrorOpeningOrReadingCubeFile"), e); //$NON-NLS-1$
}
finally
{
try
{
if (fis!=null) fis.close();
if (dis!=null) dis.close();
}
catch(IOException ioe)
{
throw new KettleStepException(Messages.getString("CubeInputMeta.Exception.UnableToCloseCubeFile"), ioe); //$NON-NLS-1$
}
}
}
示例14: sendExport
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
/**
* Send an exported archive over to this slave server
* @param filename The archive to send
* @param type The type of file to add to the slave server (AddExportServlet.TYPE_*)
* @param load The filename to load in the archive (the .kjb or .ktr)
* @return the XML of the web result
* @throws Exception in case something goes awry
*/
public String sendExport(String filename, String type, String load) throws Exception
{
String serviceUrl=AddExportServlet.CONTEXT_PATH;
if (type!=null && load!=null) {
serviceUrl = serviceUrl+= "/?"+AddExportServlet.PARAMETER_TYPE+"="+type+"&"+AddExportServlet.PARAMETER_LOAD+"="+URLEncoder.encode(load, "UTF-8");
}
String urlString = constructUrl(serviceUrl);
log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ConnectingTo", urlString)); //$NON-NLS-1$
PutMethod putMethod = new PutMethod(urlString);
// Request content will be retrieved directly from the input stream
//
FileObject fileObject = KettleVFS.getFileObject(filename);
RequestEntity entity = new InputStreamRequestEntity(KettleVFS.getInputStream(fileObject));
putMethod.setRequestEntity(entity);
putMethod.setDoAuthentication(true);
putMethod.addRequestHeader(new Header("Content-Type", "binary/zip"));
// Get HTTP client
//
HttpClient client = new HttpClient();
addCredentials(client);
// Execute request
//
try
{
int result = client.executeMethod(putMethod);
// The status code
log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ResponseStatus", Integer.toString(result))); //$NON-NLS-1$
// the response
InputStream inputStream = new BufferedInputStream(putMethod.getResponseBodyAsStream(), 1000);
StringBuffer bodyBuffer = new StringBuffer();
int c;
while ( (c=inputStream.read())!=-1) bodyBuffer.append((char)c);
inputStream.close();
String bodyTmp = bodyBuffer.toString();
switch(result)
{
case 401: // Security problem: authentication required
// Non-internationalized message
String message = "Authentication failed"+Const.DOSCR+Const.DOSCR+bodyTmp; //$NON-NLS-1$
WebResult webResult = new WebResult(WebResult.STRING_ERROR, message);
bodyBuffer.setLength(0);
bodyBuffer.append(webResult.getXML());
break;
}
String body = bodyBuffer.toString();
// String body = post.getResponseBodyAsString();
log.logDebug(toString(), Messages.getString("SlaveServer.DEBUG_ResponseBody",body)); //$NON-NLS-1$
return body;
}
finally
{
// Release current connection to the connection pool once you are done
putMethod.releaseConnection();
log.logDetailed(toString(), Messages.getString("SlaveServer.DETAILED_SentExportToService", AddExportServlet.CONTEXT_PATH, environmentSubstitute(hostname))); //$NON-NLS-1$
}
}
示例15: getFileInputStream
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
/**
* This is not thread safe: please try to get the file appender yourself using the static constructor and work from there
*/
public InputStream getFileInputStream() throws IOException
{
return KettleVFS.getInputStream(fileAppender.getFile());
}