java - putting variables in text file then get them back in an array -
i have done of project still have one. have take data user , put 3 variables (profit2012, profit2013, profit2014), store them in text file separated commas. after want take them out of file draw them on graph (canvas). how can that?
private static int year() { scanner input = new scanner(system.in); int selectedyear; system.out.println("choose 1 of following years: "); system.out.println("[1] 2012 - - [2] 2013 - - [3] 2014"); selectedyear = input.nextint(); if (selectedyear == 1) { int expenses2012; system.out.println("please enter expenses year : "); expenses2012 = input.nextint(); int sales2012; system.out.println("please enter sales year : "); sales2012 = input.nextint(); int profit2012 = sales2012 - expenses2012; } if (selectedyear == 2) { int expenses2013; system.out.println("please enter expenses year : "); expenses2013 = input.nextint(); int sales2013; system.out.println("please enter sales year : "); sales2013 = input.nextint(); int profit2013 = sales2013 - expenses2013; } if (selectedyear == 3) { int expenses2014; system.out.println("please enter expenses year : "); expenses2014 = input.nextint(); int sales2014; system.out.println("please enter sales year : "); sales2014 = input.nextint(); int profit2014 = sales2014 - expenses2014; }try { main(null); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } as see, have variables, , graph ready, not know how put them in text file read array use them height of 3 rectangles (separating them in places of commas).
use objectoutputstream , write collections object file. later on cen collection same object via objectinputstream
Comments
Post a Comment