import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import javax.print.DocFlavor;
import javax.print.StreamPrintService;
import javax.print.StreamPrintServiceFactory;
import javax.print.attribute.standard.OrientationRequested;
public class Main {
public static void main(String[] argv) throws Exception {
OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps"));
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
StreamPrintService service = factories[0].getPrintService(fos);
Class category = OrientationRequested.class;
Object o = service.getSupportedAttributeValues(category, null, null);
if (o == null) {
System.out.println("Attribute is not supported");
} else if (o.getClass() == category) {
System.out.println("irrelevant");
} else if (o.getClass().isArray()) {
System.out.println("array");
for (int i = 0; i < Array.getLength(o); i++) {
Object v = Array.get(o, i);
System.out.println(v);
}
}
}
}