System.out.println("Starting Output");
updateStatus("Starting Output");
   private void cvtToText() {      java.io.PrintStream dw;      try {         openOutputFile();         dw = new java.io.PrintStream(fw);         // Create an AS400 object.  The system name was passed         // as the first command line argument.         AS400 system = new AS400 (systemName.getText());         String splfName = spooledFile.getText();         int splfNumber = Integer.parseInt(spooledFileNumber.getText());         String _jobName = jobName.getText();         String _jobUser = user.getText();         String _jobNumber = number.getText();         SpooledFile splF = new SpooledFile(system,         splfName,         splfNumber,         _jobName,         _jobUser,         _jobNumber);         PrintParameterList printParms = new PrintParameterList();         printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT,         "/QSYS.LIB/QWPDEFAULT.WSCST");         printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");         // get the text (via a transformed input stream) from the spooled file         PrintObjectTransformedInputStream inStream = splF.getTransformedInputStream(printParms);         //            DataInputStream dis = new DataInputStream(inStream);         BufferedReader br = new BufferedReader(                    new InputStreamReader(inStream));         // get the number of available bytes         int avail = inStream.available();         byte[] buf = new byte[avail + 1];         int read = 0;         int totBytes = 0;         StringBuffer sb = new StringBuffer();         System.out.println("Starting Output");         // read the transformed spooled file, creating the jobLog String         while (avail > 0) {            if (avail > buf.length) {               buf = new byte[avail + 1];            }            read = inStream.read(buf, 0, avail);            for (int x = 0; x < read; x++) {               switch (buf[x]) {                  case 0x0:      // 0x00                     break;                  // write line feed to the stream                  case 0x0A://                     writeChar(sb.toString());//                     sb.append((char)buf[x]);                     dw.println(sb.toString().toCharArray());                     sb.setLength(0);//                     sb.append('\n');//                     System.out.print(sb);//                     sb.setLength(0);                     break;                  // we will skip the carrage return                  case 0x0D://                     sb.append('\n');//                     writeChar("\n");//                     System.out.println();                     break;                  // new page                  case 0x0C://                     writeChar(sb.toString());//                     dw.write(sb.toString().getBytes());//                     document.newPage();                     dw.println(sb.toString().toCharArray());                     sb.setLength(0);                     break;                  default:                     sb.append((char)buf[x]);               }            }//            dw.write(buf);            totBytes += read;            updateStatus("Bytes read " + totBytes);//            System.out.println("Bytes read " + byr);//            System.out.println(new String(buf));            //            // process the data buffer            //            avail = inStream.available();         }         if (sb.length() > 0)            dw.println(sb.toString().toCharArray());         dw.flush();         dw.close();         updateStatus("Total bytes converted " + totBytes);         if (email.isSelected())            emailMe();        }        catch (Exception e) {           updateStatus("Error: " + e.getMessage ());           System.out.println ("Error: " + e.getMessage ());        }   }