当前位置: 首页>>代码示例>>Java>>正文


Java KettleVFS.getInputStream方法代码示例

本文整理汇总了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);
		}
	}

}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:22,代码来源:ImageUtil.java

示例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();
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:20,代码来源:YamlReader.java

示例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;
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:37,代码来源:JobEntryFileCompare.java

示例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;
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:39,代码来源:JobEntryFoldersCompare.java

示例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);
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:37,代码来源:XBaseInput.java

示例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);
	}
  
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:32,代码来源:GetFilesRowsCount.java

示例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;
}
 
开发者ID:brosander,项目名称:kettle-plugins,代码行数:16,代码来源:KThinJobEntryImageServlet.java

示例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;
}
 
开发者ID:brosander,项目名称:kettle-plugins,代码行数:12,代码来源:KThinJobEntryImageServlet.java

示例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;
    }
  }

}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:GetFilesRowsCount.java

示例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$
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:40,代码来源:CubeInputMeta.java

示例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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:62,代码来源:SpatialAnalysis.java

示例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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:42,代码来源:CubeInput.java

示例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$
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:42,代码来源:CubeInputMeta.java

示例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$
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:79,代码来源:SlaveServer.java

示例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());
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:8,代码来源:LogWriter.java


注:本文中的org.pentaho.di.core.vfs.KettleVFS.getInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。