gpt4 book ai didi

java - 读取所有页面的 AS400 假脱机文件 - JAVA (JT400)

转载 作者:行者123 更新时间:2023-12-03 23:05:32 28 4
gpt4 key购买 nike

我正在尝试在 JAVA 中读取 AS400 假脱机文件。我使用这段代码阅读了它。但问题是它只检索该假脱机文件的一页详细信息。但我想阅读并获取所有页面的详细信息。有人知道怎么做吗?

提前致谢!

代码:

try {
jTextArea1.setText(null);
DefaultTableModel DTM =(DefaultTableModel) jTable1.getModel();
int SR = jTable1.getSelectedRow();

String SPLFNAME = (String) DTM.getValueAt(SR, 0);
String SPLFNUMBERT = (String) DTM.getValueAt(SR, 1);
String JOBNAME = (String) DTM.getValueAt(SR, 3);
String JOBUSER = (String) DTM.getValueAt(SR, 4);
String JOBFNUMBER = (String) DTM.getValueAt(SR, 5);

int SPLNO = Integer.parseInt(SPLFNUMBERT);

AS400 sys = new AS400();
SpooledFile sf = new SpooledFile( sys, // AS400
SPLFNAME, // splf name
SPLNO, // splf number
JOBNAME, // job name
JOBUSER, // job user
JOBFNUMBER ); // job number

PrintParameterList printParms = new PrintParameterList();
printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPDEFAULT.WSCST");
printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");

// Create a page input stream from the spooled file
PrintObjectPageInputStream is = sf.getPageInputStream(printParms);

BufferedReader d = new BufferedReader(new InputStreamReader(is));
String data ="";
while((data = d.readLine() )!=null)
{
System.out.println (data);

jTextArea1.setText(jTextArea1.getText()+"\n"+data);
}
} catch (Exception e) {
System.out.println(e);
}

最佳答案

PrintObjectPageInputStream类有一个 nextPage() 移动到下一页的方法。

BufferedReader d = new BufferedReader(new InputStreamReader(is));
String data = "";
do {
while((data = d.readLine()) != null)
{
System.out.println (data);
jTextArea1.setText(jTextArea1.getText()+"\n"+data);
}
} while (d.nextPage());


使用 PrintObjectTransformedInputStream无需分页即可读取整个假脱机文件。

关于java - 读取所有页面的 AS400 假脱机文件 - JAVA (JT400),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18480014/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com