FileWriteApp -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
package lab4; import java.util.*; import java.io.*; public class FileWriteApp { p public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("File Name: >"); String input = console.next(); FileRead file = new FileRead(input); String line = file.readLine(); String [] tokenArray; System.out.println("Choose a name for Early Snow file >"); String output1 = console.next(); System.out.println("Choose a name for Late Snow file"); String output2 = console.next(); try{ FileWrite file1 = new FileWrite(output1); file1.writeToObject("City"+"\tJanuary"+"\tDecember"+"\tAverage"); FileWrite file2 = new FileWrite(output2);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: file2.writeToObject("City"+"\tJanuary"+"\tDecember"+"\tAverage"); while(line!= null) { tokenArray = line.split("\t"); if(Double.parseDouble(tokenArray[13]) > Double.parseDouble(tokenArray[2])) { file1.writeToObject(tokenArray[0]+"\t"+tokenArray[2]+"\t"+tokenArray[13]+"\t"+token Array[14]); } else { file2.writeToObject(tokenArray[0]+"\t"+tokenArray[13]+"\t"+tokenArray[2]+"\t"+token Array[14]); } } file1.close(); file2.close(); }catch(IOException ioe){ioe.printStackTrace();} System.out.println("File '"+output1 + "' and File '"+output2+"' have been written"); }}...
View Full Document

Ask a homework question - tutors are online