Sorting a text file in Java

17,451

This is a simple four step process, with three of the four steps addressed by Stackoverflow Questions:

  1. Read each line and turn them into Java String
  2. Store each Java String in a Array (don't think you need a reference for this one.)
  3. Sort your Array
  4. Write out each Java String in your array
Share:
17,451
user2205055
Author by

user2205055

Updated on June 04, 2022

Comments

  • user2205055
    user2205055 almost 2 years

    I have a text file with a list of words which I need to sort in alphabetical order using Java. The words are located on seperate lines.

    How would I go about this, Read them into an array list and then sort that??

  • Jazzepi
    Jazzepi about 11 years
    +1 for referencing posts that already exist, and not being a jerk about it