我正在使用 IBM MQ
并在 queue
上放置一条消息,我需要捕获错误代码,例如:
MQJE001: Completion Code '2' Reason '2035'
我的问题是读取此错误代码,我的 java 程序通过以下方式读取输出:
BufferReader reader = new BufferReader(new InputStreamReader(processSH.getInputStream())); // processSH - the process that is putting message on queue
如果没有错误代码,我可以用这种方式读取输出,但我无法使用 :
String line = null;
while(line.reader.readLine()) != null){
system.out.println(line) // prints nothing in case of error
}
感谢所有帮助者!
最佳答案
我认为问题出在这段代码中:
String line = null;
while(line.reader.readLine()) != null){
system.out.println(line) // prints nothing in case of error
}
我什至不确定你是如何编译它的。 reader
不是 String
的属性。我认为该行应为:
while(line = reader.readLine()) != null){
关于java - 从 java 中捕获 MQ 错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36382464/