PipedOutputStream spsOutStream = new PipedOutputStream();
PipedInputStream clientInputStream = new PipedInputStream(
spsOutStream);
DocFlavor newFlavor = null;
StreamPrintServiceFactory spsf = null;
DocFlavor clientFlavors[] = printClient
.getSupportedDocFlavors();
for (int i = 0; i < clientFlavors.length; i++) {
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
.lookupStreamPrintServiceFactories(userDocDF,
clientFlavors[i].getMimeType());
if (factories.length > 0
&& Class.forName(
clientFlavors[i]
.getRepresentationClassName())
.isInstance(clientInputStream)) {
spsf = factories[0];
newFlavor = clientFlavors[i];
break;
}
}
if (spsf != null) {
StreamPrintService sps = spsf.getPrintService(spsOutStream);
/*
* Constructing new Doc object for client: - connecting
* InputStream of client with OutputStream of
* StreamPrintSrevice - constructing DocFlavor for