Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package realestate;
- import java.io.*;
- import java.util.*;
- import java.io.File;
- import java.lang.*;
- /**
- *
- * @author Colin
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- String[] InitialArray;
- int[] PropertyID;
- String[] PropertyType;
- double[] PropertyValue;
- double[] CompletePropertyValue;
- int[] AgentID;
- int counter=0;
- int arraySize = 0;
- int arraySize2 = 0;
- System.out.print("Where is the text file located: ");
- Scanner input =new Scanner(System.in);
- String FileLocation = input.next();
- try{
- FileInputStream fis2 = new FileInputStream(FileLocation);
- DataInputStream dis2 = new DataInputStream(fis2);
- BufferedReader br2 = new BufferedReader(new InputStreamReader(dis2));
- String Writing;
- while((Writing=br2.readLine())!=null){
- arraySize++;
- }
- br2.close();
- FileInputStream fis = new FileInputStream(FileLocation);
- DataInputStream dis = new DataInputStream(fis);
- BufferedReader br = new BufferedReader(new InputStreamReader(dis));
- PropertyID = new int[arraySize];
- PropertyType = new String[arraySize];
- PropertyValue = new double[arraySize];
- CompletePropertyValue = new double[arraySize];
- AgentID = new int[arraySize];
- String Writing2;
- int SetCounter=0;
- while((Writing2=br.readLine())!=null){
- //System.out.print(Writing);
- InitialArray = Writing2.split("\\s+");
- for (int j = 0; j < InitialArray.length; j++) {
- if(j==0)
- {
- //System.out.println(InitialArray[j]);
- PropertyID[SetCounter] = Integer.parseInt(InitialArray[j]);
- //System.out.print("Worked");
- }
- if(j==1)
- {
- //System.out.println(InitialArray[j]);
- PropertyType[SetCounter]=InitialArray[j];
- }
- if(j==2)
- {
- //System.out.println(InitialArray[j]);
- PropertyValue[SetCounter] = Double.parseDouble(InitialArray[j]);
- }
- if(j==3)
- {
- //System.out.println(InitialArray[j]);
- AgentID[SetCounter]=Integer.parseInt(InitialArray[j]);
- }
- }
- SetCounter++;
- }
- br.close();
- for (int i = 0; i < PropertyType.length; i++) {
- PropertyType[i].toUpperCase();
- }
- Arrays.sort(PropertyType);
- // int tempcount = 0;
- // for(int i : AgentID){
- // for(int j : AgentID){
- // if(i==j)
- // {
- // tempcount++;
- // }
- // }
- // }
- //
- // int tc[]=new int[tempcount];
- // String[] LinkedArrays= new String[arraySize];
- // for (int i = 0; i < AgentID.length; i++) {
- // LinkedArrays[i] = (AgentID[i] + " " + PropertyValue[i]);
- // }
- // Arrays.sort(LinkedArrays);
- // for (int i = 0; i < LinkedArrays.length; i++) {
- // String[] TempStringArray = new String[arraySize];
- // TempStringArray = LinkedArrays[i].split("\\s+");
- // AgentID[i]= Integer.parseInt(TempStringArray[0]);
- // PropertyValue[i] = Double.parseDouble(TempStringArray[1]);
- // }
- // int placeHolder = 0;
- // for (int i = 0; i < AgentID.length-1; i++) {
- // if(AgentID[i]==AgentID[i++])
- // {
- // tc[placeHolder] += (PropertyValue[i]+PropertyValue[i++]);
- // }
- // else
- // {
- // placeHolder++;
- // }
- //
- // }
- // for (int i = 0; i < LinkedArrays.length; i++) {
- // System.out.println(AgentID[i] +" "+ tc[i]);
- //
- // }
- File file = new File("D:\\AgentReport.txt");
- file.createNewFile();
- FileWriter rty=new FileWriter(file);
- BufferedWriter bw = new BufferedWriter(rty);
- for (int i = 0; i < PropertyType.length; i++) {
- bw.append(PropertyType[i]);
- bw.newLine();
- }
- for (int i = 0; i < AgentID.length; i++) {
- bw.append(AgentID[i] + " "+ PropertyValue[i]+"\n");
- bw.newLine();
- }
- bw.close();
- }
- catch(IOException e)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment