I'm wondering how to do something only if Integer.parseInt(whatever) doesn't fail.
More specifically I have a jTextArea of user specified values seperated by line breaks.
I want to check each line to see if can be converted to an int.
Figured something like this, but it doesn't work:
for(int i = 0; i < worlds.jTextArea1.getLineCount(); i++){
if(Integer.parseInt(worlds.jTextArea1.getText(worlds.jTextArea1.getLineStartOffset(i),worlds.jTextArea1.getLineEndOffset(i)) != (null))){}
}
Any help appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…