cbfs
  • Introduction
  • Intro
    • Release History
    • About This Book
  • Getting Started
    • Installation
    • Providers
      • Local Provider
      • RAM Provider
      • S3 Provider
  • Usage
    • Disk Service
    • Disk Usage
      • Configuration Methods
      • File Methods
      • File Object
      • Directory Methods
      • Utility Methods
      • Stream Methods
      • Verification Methods
  • Digging Deeper
    • Interceptors
    • Module Disks
    • Custom Providers
Powered by GitBook
On this page
  • stream
  • streamOf

Was this helpful?

Edit on GitHub
Export as PDF
  1. Usage
  2. Disk Usage

Stream Methods

The stream methods are only available for the LocalProvider currently.

stream

Returns a Java stream of the file using non-blocking IO classes. The stream will represent every line in the file so you can navigate through it.

/**
 * @path The path to read all the files with
 *
 * @return Stream object: See https://apidocs.ortussolutions.com/coldbox-modules/cbstreams/1.1.0/index.html
 */
function stream( required path );

// Example
disk.stream( expandPath( "datadump.txt" ) );

streamOf

Create a Java stream of the incoming array of files or directories.

/**
 * @target The target array of files/directories to generate a stream of
 *
 * @return Stream object: See https://apidocs.ortussolutions.com/coldbox-modules/cbstreams/1.1.0/index.html
 */
function streamOf( required array target ){
	
// Example
disk.streamOf( disk.files( "my.path" ) )
	.filter( function( item ){
		return item.startsWith( "a" );
	} )
	.forEach( function( item ){
		writedump( item );	
	} );

PreviousUtility MethodsNextVerification Methods

Last updated 2 years ago

Was this helpful?