Java Code Examples for org.pentaho.di.trans.step.BaseStep#closeQuietly()
The following examples show how to use
org.pentaho.di.trans.step.BaseStep#closeQuietly() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetFilesRowsCount.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (GetFilesRowsCountMeta) smi; data = (GetFilesRowsCountData) sdi; if ( data.file != null ) { try { data.file.close(); data.file = null; } catch ( Exception e ) { log.logError( "Error closing file", e ); } } if ( data.fr != null ) { BaseStep.closeQuietly( data.fr ); data.fr = null; } if ( data.lineStringBuilder != null ) { data.lineStringBuilder = null; } super.dispose( smi, sdi ); }
Example 2
Source File: TextFileInput.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (TextFileInputMeta) smi; data = (TextFileInputData) sdi; if ( data.file != null ) { try { data.file.close(); data.file = null; } catch ( Exception e ) { log.logError( "Error closing file", e ); } } if ( data.in != null ) { BaseStep.closeQuietly( data.in ); data.in = null; } super.dispose( smi, sdi ); }
Example 3
Source File: BlockingStep.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { if ( ( data.dis != null ) && ( data.dis.size() > 0 ) ) { for ( DataInputStream is : data.dis ) { BaseStep.closeQuietly( is ); } } // remove temp files for ( int f = 0; f < data.files.size(); f++ ) { FileObject fileToDelete = data.files.get( f ); try { if ( fileToDelete != null && fileToDelete.exists() ) { fileToDelete.delete(); } } catch ( FileSystemException e ) { logError( e.getLocalizedMessage(), e ); } } super.dispose( smi, sdi ); }
Example 4
Source File: GetXMLData.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void dispose( StepMetaInterface smi, StepDataInterface sdi ) { meta = (GetXMLDataMeta) smi; data = (GetXMLDataData) sdi; if ( data.file != null ) { try { data.file.close(); } catch ( Exception e ) { // Ignore close errors } } if ( data.an != null ) { data.an.clear(); data.an = null; } if ( data.NAMESPACE != null ) { data.NAMESPACE.clear(); data.NAMESPACE = null; } if ( data.NSPath != null ) { data.NSPath.clear(); data.NSPath = null; } if ( data.readrow != null ) { data.readrow = null; } if ( data.document != null ) { data.document = null; } if ( data.fr != null ) { BaseStep.closeQuietly( data.fr ); } if ( data.is != null ) { BaseStep.closeQuietly( data.is ); } if ( data.files != null ) { data.files = null; } super.dispose( smi, sdi ); }
Example 5
Source File: GetFilesRowsCount.java From pentaho-kettle with Apache License 2.0 | 4 votes |
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; boolean prevCR = false; while ( ( n = data.fr.read( buf ) ) != -1 ) { for ( int i = 0; i < n; i++ ) { data.foundData = true; if ( meta.getRowSeparatorFormat().equals( "CRLF" ) ) { // We need to check for CRLF if ( buf[i] == '\r' || buf[i] == '\n' ) { if ( buf[i] == '\r' ) { // we have a carriage return // keep track of it..maybe we will have a line feed right after :-) prevCR = true; } else if ( buf[i] == '\n' ) { // we have a line feed // let's see if we had previously a carriage return if ( prevCR ) { // we have a carriage return followed by a line feed data.rownr++; // Maybe we won't have data after data.foundData = false; prevCR = false; } } } else { // we have another char (other than \n , \r) prevCR = false; } } else { if ( buf[i] == data.separator ) { data.rownr++; // Maybe we won't have data after data.foundData = false; } } } } } if ( 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; } } }