Friday, 15 March 2013

How to print this output in text file in java? -



How to print this output in text file in java? -

i have calculated words , displaying in console. want write console output text file. how this?

string[] wrds = counter.getwords(wordcounter.sortorder.by_frequency); int[] frequency = counter.getfrequencies(wordcounter.sortorder.by_frequency); int n = counter.getentrycount(); (int i=0; i<n; i++) { should written in text file///// system.out.println(frequency[i] + " " + wrds[i]+" "+ counter.getwordcount());

string[] wrds = counter.getwords(wordcounter.sortorder.by_frequency); int[] frequency = counter.getfrequencies(wordcounter.sortorder.by_frequency); string texttowrite = ""; int n = counter.getentrycount(); (int i=0; i<n; i++) { texttowrite += frequency[i] + " " + wrds[i]+" "+ counter.getwordcount(); } try{ filewriter fstream = new filewriter("out.txt"); bufferedwriter out = new bufferedwriter(fstream); out.write(texttowrite); out.close(); }catch (exception e){ system.err.println("error: " + e.getmessage()); } }

java file io

No comments:

Post a Comment