所以,我有一个循环遍历数组然后执行try / catch以查看是否可以从原始字符串值中获取任何索引。
for (int i = 0; i < recordLine.split("\t").length; i++) {
try {
long l = Integer.parseInt(recordLine.split("\t")[i]);
} catch (NumberFormatException numberFormatException) {
System.out.println("Here are the Strings: " + i);
System.out.println("NumberFormatException: " + numberFormatException.getMessage());
}
}
答案 0 :(得分:0)
String[] splitRecordLineItems = recordLine.split("\t");
Character[] resultsArray = new Character[splitRecordLineItems.length];
for (int i = 0; i < splitRecordLineItems.length; i++) {
try {
long l = Long.parseLong(splitRecordLineItems[i]);
resultsArray[i] = 'L';
} catch (NumberFormatException nfe) {
resultsArray[i] = 'S';
}
}
然后,您可以使用以下行打印resultsArray的内容:
System.out.println(Arrays.toString(resultsArray));