java - JT400 - 显示 SpooledFile 的内容

标签 java ibm-midrange jt400

我尝试使用库 jt40 显示 SpooledFile 的内容。 我使用这段代码:

public static void printJogLog(AS400 as400, Job j) {
    SpooledFile spooledFile = new SpooledFile(as400, "QPJOBLOG", 1, j.getName(), j.getUser(), j.getNumber());

    try {
        PrintParameterList printParms = new PrintParameterList();
        printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPDEFAULT.WSCST");
        printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");
        PrintObjectPageInputStream is = spooledFile.getPageInputStream(printParms);
        PrintObjectTransformedInputStream in = spooledFile.getTransformedInputStream(printParms);

        byte[] buf = new byte[32767];
        StringBuffer sbuf = new StringBuffer();
        int bytesRead = 0;
        do {
            bytesRead = in.read(buf);
            if (bytesRead != -1) { // process the spooled file data.
                sbuf.append(new String(buf, 1, bytesRead, "CP936"));
            }
        } while (bytesRead != -1);
        System.out.println(sbuf.toString());

        BufferedReader d = new BufferedReader(new InputStreamReader(is, "UTF8"));
        String data = "";
        String pageSpool = "";
        while ((data = d.readLine()) != null) {
            pageSpool += data + "\n";
        }
        System.out.println(pageSpool);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

它打印 SpooledFile 的内容,但我在处理特殊字符时遇到问题。 我得到这样的东西:

CPF412C Echappement 40 12/02/15 17:08:33,699347 QTAERR QSYS 00EA QSRVALDV QSYS *STMT Module de destination . . . : QSRVALDV Proc俤ure de destination . : OPENVOLUME Instruction . . . . . . . . : 3716 Message . . . . : Cartouche PPRD05 introuvable Cause . . . . . : La cartouche PPRD05 a 倀� indiqu俥 pour l'unit� de bandoth妐ue TAPVTL01, mais elle n'existe pas dans l'unit� TAPVTL01. Que faire . . . : Effectuez l'une des op俽ations suivantes, puis renouvelez votre demande : -- Sp俢ifiez un identificateur de cartouche correct ou ins俽ez la cartouche dans la biblioth妐ue. La cartouche en a peut-坱re 倀� retir俥. -- Si vous avez indiqu� VOL(*MOUNT), l'identificateur de la cartouche n'a peut-坱re pas 倀� d倀ermin�. Indiquez une cartouche pour le param妕re VOL. -- Si l'incident persiste, mettez l'unit� hors fonction, puis remettez-la en fonction � l'aide de la commande VRYCFG (Changer l'倀at d'une configuration) en indiquant le param妕re RESET(*YES). -- Si la commande ADDTAPCTG (Ajouter une cartouche de bande) a 倀� 俶ise, il se peut que la cartouche ait 倀� retir俥 du guichet en libre-service avant son utilisation.

我认为我需要为 PrintObjet 设置一些参数,但我不知道如何选择好的参数和值。

有人可以解释一下如何知道我需要哪个参数吗?

最佳答案

我在这里找到了解决方案: http://fixunix.com/ibm-as400/258696-java-read-french-spool.html

我这样修改我的函数:

public static void printJobLog2(AS400 as400, Job job) {
    SpooledFile spooledFile = new SpooledFile(as400, "QPJOBLOG", 1, job.getName(), job.getUser(), job.getNumber());
    PrintParameterList printParms = new PrintParameterList();
    printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPDEFAULT.WSCST");
    printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");
    try {
        InputStreamReader in = new
                InputStreamReader(spooledFile.getTransformedInputStream(printParms), "cp850");
        char[] buf = new char[32767];
        StringBuffer sbuf = new StringBuffer();
        if (in.ready()) {
            int bytesRead = 0;
            bytesRead = in.read(buf, 0, buf.length);
            while (bytesRead > 0) {
                sbuf.append(buf, 0, bytesRead);
                bytesRead = in.read(buf, 0, buf.length);
            }
        }
        System.out.println(sbuf.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

现在可以了。

CPF412C Echappement 40 16/02/15 08:55:14,184776 QTAERR QSYS 00EA QSRVALDV QSYS *STMT Module de destination . . . : QSRVALDV Procédure de destination . : OPENVOLUME Instruction . . . . . . . . : 3716 Message . . . . : Cartouche SCOH07 introuvable Cause . . . . . : La cartouche SCOH07 a été indiquée pour l'unité de bandothèque TAPVTL01, mais elle n'existe pas dans l'unité TAPVTL01.

关于java - JT400 - 显示 SpooledFile 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28483348/

相关文章:

java - 不支持请求方法 'HEAD'

java - 该方法必须覆盖或实现父类(super class)方法

java反射创建字段/值 HashMap

java - 保持 JVM 在 iseries 上运行

ibm-midrange - IBM i 确定可用的编程语言

C# ADO.NET IBM DB2 命名参数具有相同的名称抛出没有足够的参数指定异常

java - 如何将数据库添加到 swing 桌面应用程序

java - 如何从使用 Java 的客户端在 Sybase IQ 中加载表?

java - 从 Java/JT400 SQL 语句触发 DB2/OS/400 触发器

java - 如何获取 as400 (jt400) 登录用户列表