[nbusers] Read in from file to array and sort

  • From: "tuts73" < >
  • To:
  • Subject: [nbusers] Read in from file to array and sort
  • Date: Sat, 31 Mar 2012 16:53:57 +0000

Hi all, im new to Java and just wondering if you could help out.....
I have a list of names in a standard text file that need to be sorted. Im 
guessing the best way to do this is to read the contents of the file and 
store in an array, then use a sorting algorithm to sort the contents.
So far i have been able to read in the file - but now struggling to apply 
some code to store and sort......would appriciate any help. Thanks :) 
The code i have so far.....
public class MSL{

public static void main(String[] args)throws IOException{
 String contents;
 File f = new File("MyList.txt");
 FileReader fr = new FileReader(f);
 BufferedReader br = new BufferedReader(fr);
 while (br.ready()){
 contents = br.readLine();

[nbusers] Read in from file to array and sort

tuts73 03/31/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 25 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm