Discovering Streams in an Application



Introduction

This example demonstrates how to find Streams of different types in an Application.

// Look up all streaming factories
StreamPrintServiceFactory[] factories
    = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(null, null);

// Find all streaming factories that support particular input formats;
// in this case, GIF and postscript
factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
    DocFlavor.INPUT_STREAM.GIF,
    DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());

// Use a factory to create a print service.
// An output stream is required to create a print service.
OutputStream fos = new BufferedOutputStream(
    new FileOutputStream("outfile.ps"));
StreamPrintService service = factories[0].getPrintService(fos);

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.