Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 07:03 PM
Member
 
Join Date: Apr 2008
Posts: 15
mark-mlt is on a distinguished road
sorting problem...
Im trying to load data from a text file ghax display it in a text area and load the contents of the file in alphabetical order; the following piece of code which i cant get working; any one can help pls!


------------------------------------------
private void test() {
{

try {
in = new BufferedReader(
new FileReader(
new File(
"C:\\test.txt")));

// Declare Array which will hold 10 lines
String[] myarray;
int n = 10;
String lineContent = null;

myarray = new String[n];

// Read each line into the array
for (int i = 0; i < myarray.length; i++) {
myarray[i] = in.readLine();

int currentLine = 0;
// this will be set to true if the string was found
while (true) {
currentLine++;
// get a line of text from the file
try {
lineContent = in.readLine();
} catch (IOException e) {
break;
}



String str = null;// = lineContent;
StringTokenizer st = new StringTokenizer(str);

if (st.countTokens() > 1) {

System.out.println("Number of Words: " +
st.countTokens() );
Arrays.sort(myarray);
System.out.println("Sorted Strings: " + "\n"+ Arrays.asList(myarray)+"\n");}

}
}
}



catch (IOException e) {
lineLabel.setText("Error Opening Text File");
JOptionPane.showMessageDialog(null,
"The File cannot be opened.", "Information",
JOptionPane.INFORMATION_MESSAGE);

}
}

}

--------------------the end -------------
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-16-2008, 10:22 PM
Member
 
Join Date: Apr 2008
Posts: 15
mark-mlt is on a distinguished road
no helpp?? :S
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 04:38 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 524
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
And what is you problem?

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 07:52 AM
Member
 
Join Date: Apr 2008
Posts: 15
mark-mlt is on a distinguished road
its not working ...
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 03:15 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 524
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Which part is not working?

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting problem mcal New To Java 1 02-14-2008 09:13 AM
Problem with sorting Table sireesha264 Advanced Java 0 02-08-2008 03:21 PM
Sorting JTable (Vectors) Problem ramapple AWT / Swing 5 02-05-2008 09:54 AM
Heap Sorting kesav2005 New To Java 1 11-13-2007 05:04 PM
sorting JTable mansi_3001 Advanced Java 3 08-10-2007 07:29 PM


All times are GMT +3. The time now is 04:31 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org