1

我尝试使用库 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 目标模块。. . : QSRVALDV Proc俤ure de destination 。: 开卷指令。. . . . . . . : 3716 消息。. . . : 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。阙阙。. . : Effectuez l'une des op俽ations suvantes, 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(*是的)。-- Si la commande ADDTAPCTG (Ajouter une cartouche de bande) a 伥� 俶ise,

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

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

4

2 回答 2

1

我在这里找到了一个解决方案: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 目标模块。. . : QSRVALDV 目的地程序。: 开卷指令。. . . . . . . : 3716 消息。. . . : 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。

于 2015-02-16T08:29:19.893 回答
0

看起来像 CCSID 不匹配。您确定要使用 UTF8 打开 InputStreamReader 吗?试着BufferedReader d = new BufferedReader(new InputStreamReader(is));让机器决定字符集。

于 2015-02-13T14:29:08.417 回答