gpt4 book ai didi

java - 如何阻止 Java/Eclipse 将 stdout 和 stderr 混合在一起?

转载 作者:行者123 更新时间:2023-12-01 16:59:07 25 4
gpt4 key购买 nike

这是我正在处理的程序中得到的输出:

java.lang.IllegalArgumentException: argument type mismatch
CreationDate
getCreationDate
setCreationDate
LastModifiedDate
getLastModifiedDate
setLastModifiedDate
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at Transform.transform(Transform.java:86)
at Experiment.main(Experiment.java:120)
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at Transform.transform(Transform.java:86)
at Experiment.main(Experiment.java:120)
DeletionDate
getDeletionDate
setDeletionDate

调用它的代码:

    for (Field f : databaseFields) {
String upperCamelCase = Character.toUpperCase(f.getName().charAt(0)) + f.getName().substring(1);
System.out.println(upperCamelCase);

String getMethodName = "get" + upperCamelCase;
System.out.println(getMethodName);

Method getMethod = null;
try {
getMethod = databaseClass.getDeclaredMethod(getMethodName);
} catch (NoSuchMethodException e) {
} catch (SecurityException e) { }

if (getMethod == null) {
getMethodName = "is" + upperCamelCase;
try {
getMethod = databaseClass.getDeclaredMethod(getMethodName);
} catch (NoSuchMethodException e) {
continue;
} catch (SecurityException e) {
continue;
}
}

String setMethodName = "set" + upperCamelCase;
System.out.println(setMethodName);
Method setMethod = null;
for (int i = 0; i < parameterTypes.length; i++) {
try {
setMethod = jsonClass.getDeclaredMethod(setMethodName, parameterTypes[i]);
} catch (NoSuchMethodException e) { }
}

if (setMethod == null) {
continue;
}

try {
setMethod.invoke(jsonObject, getMethod.invoke(databaseObject));
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}

这是用于反射转换,显然我无法判断它在哪个 get 或 set 方法上引发异常。我该如何解决这个问题?

最佳答案

在 Eclipse 中,Console 中的 stderr 和 stdout 的颜色不同。您还可以通过右键单击控制台窗口并选择“首选项”来隐藏其中之一。

在命令行中,您可以使用重定向 >2> 将 stderr 或 stdout 发送到单独的文件。

关于java - 如何阻止 Java/Eclipse 将 stdout 和 stderr 混合在一起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29106147/

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