File Input Stream

Getting Data from a file

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 4522 Views - Last Post: 18 September 2010 - 10:00 PM Rate Topic: -----

#16 admum   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-September 10

Re: File Input Stream

Posted 17 September 2010 - 12:33 PM

View Postg00se, on 17 September 2010 - 09:46 AM, said:

Just use a Scanner

    private javax.swing.ComboBoxModel getInterestRatesModel() {
	javax.swing.DefaultComboBoxModel result = null;
	String filename = "rates.txt";
	java.util.Scanner s = null;
	try {
	    result = new javax.swing.DefaultComboBoxModel();
	    s = new java.util.Scanner(new File(filename));
	    while(s.hasNextLine()) {
		result.addElement(s.nextLine());
	    }
	}
	catch(IOException e) {
	    e.printStackTrace();	
	}
	finally {
	    try { s.close() ; } catch(Exception e) { /* ignore */ }	
	}
	return result;
    }




Thanks G00se
Now I am on to trying to write a graph chart to show the results.
Was This Post Helpful? 0
  • +
  • -

#17 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: File Input Stream

Posted 18 September 2010 - 12:09 AM

Quote

Now I am on to trying to write a graph chart to show the results.


Try using JFreeChart
Was This Post Helpful? 0
  • +
  • -

#18 admum   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-September 10

Re: File Input Stream

Posted 18 September 2010 - 04:25 AM

View Postg00se, on 17 September 2010 - 09:46 AM, said:

Just use a Scanner

    private javax.swing.ComboBoxModel getInterestRatesModel() {
	javax.swing.DefaultComboBoxModel result = null;
	String filename = "rates.txt";
	java.util.Scanner s = null;
	try {
	    result = new javax.swing.DefaultComboBoxModel();
	    s = new java.util.Scanner(new File(filename));
	    while(s.hasNextLine()) {
		result.addElement(s.nextLine());
	    }
	}
	catch(IOException e) {
	    e.printStackTrace();	
	}
	finally {
	    try { s.close() ; } catch(Exception e) { /* ignore */ }	
	}
	return result;
    }




Thanks G00se,got it working.
now I am on to creating a chart to show the principle and interest history

View Postg00se, on 17 September 2010 - 11:09 PM, said:

Quote

Now I am on to trying to write a graph chart to show the results.


Try using JFreeChart


our instructor wants us to keep it in swing and awt

This post has been edited by admum: 18 September 2010 - 04:25 AM

Was This Post Helpful? 0
  • +
  • -

#19 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: File Input Stream

Posted 18 September 2010 - 10:00 PM

drawPolyline should do the trick

http://download.orac...rawPolyline(int[], int[], int)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2