मुझे सहायता चाहिए। इस विशिष्ट विधि के लिए। मैं इसे एक सरणी सूची लौटने की कोशिश कर रहा हूं जिसे मैंने टोकननाइज्ड किया था।किसी विधि से एक सरणीसूची को वापस कैसे करें
public ArrayList read(){
BufferedReader inputStream = null;
try {
inputStream = new BufferedReader(new FileReader("processes1.txt"));
String l;
while ((l = inputStream.readLine()) != null) {
ArrayList<String> tokens = new ArrayList<String>();
Scanner tokenize = new Scanner(l);
while (tokenize.hasNext()) {
tokens.add(tokenize.next());
}
return tokens;
}
} catch(IOException ioe){
ArrayList<String> nothing = new ArrayList<String>();
nothing.add("error1");
System.out.println("error");
//return nothing;
}
return tokens;
}
मैं क्या गलत कर रहा हूं ?!
बस एक टिप्पणी के रूप में, यह अच्छा अभ्यास सामान्य रूप में एक ArrayList के बजाय एक सूची वापस जाने के लिए, इस मामले में माना जाता है कि आपने कभी कार्यान्वयन को बदलने की जरूरत। – DJClayworth