package model;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

public class CsvReader {
	public static List<PointDescriptor> readFile(String filename){
		LinkedList<PointDescriptor> list = new LinkedList<PointDescriptor>();
		
		File file = new File(filename);
		FileReader fr;
		try {
			fr = new FileReader(file);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return new LinkedList<PointDescriptor>();
		}
		BufferedReader br = new BufferedReader(fr);
		try {
			nextLine: for(String line = br.readLine(); line != null; line = br.readLine()){
				try {
					String[] args = line.split(",");
					double x = Double.parseDouble(args[1]);
					double y = Double.parseDouble(args[2]);
					double height = Double.parseDouble(args[3]);
					double width = Double.parseDouble(args[4]);
					list.add(new PointDescriptor(args[0], y, x, width, height));
				} catch (NumberFormatException e) {
					continue nextLine;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
			try {
				br.close();
				fr.close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			return new LinkedList<PointDescriptor>();
		}
		try {
			br.close();
			fr.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return list;
	}
}

@@ -65,16 +65,49 @@
 .File;%0D%0A
+import java.io.FileInputStream;%0D%0A
 import j
@@ -186,32 +186,113 @@
 o.IOException;%0D%0A
+import java.io.InputStreamReader;%0D%0Aimport java.io.UnsupportedEncodingException;%0D%0A
 import java.util
@@ -495,18 +495,16 @@
 or%3E();%0D%0A
-%09%09
 %0D%0A%09%09File
@@ -542,16 +542,70 @@
 File
-Reader f
+InputStream fis;%0D%0A%09%09InputStreamReader isr;%0D%0A%09%09BufferedReader b
 r;%0D%0A
@@ -617,17 +617,18 @@
  %7B%0D%0A%09%09%09f
-r
+is
  = new F
@@ -634,21 +634,75 @@
 File
-Reader(file
+InputStream(file);%0D%0A%09%09%09isr = new InputStreamReader(fis, %22Cp1252%22
 );
+%09
 %0D%0A%09%09
@@ -724,32 +724,63 @@
 tFoundException 
+%7C UnsupportedEncodingException 
 e) %7B%0D%0A%09%09%09e.print
@@ -847,31 +847,16 @@
 %0A%09%09%7D%0D%0A%09%09
-BufferedReader 
 br = new
@@ -871,17 +871,18 @@
 dReader(
-f
+is
 r);%0D%0A%09%09t
@@ -1210,24 +1210,406 @@
 (args%5B4%5D);%0D%0A
+//%09%09%09%09%09for(char i : args%5B0%5D.toCharArray())%7B%0D%0A//%09%09%09%09%09%09System.out.println(Character.toString(i) + %22: %5C%5Cu%22 + Integer.toHexString(i %7C 0x10000).substring(1) );%0D%0A//%09%09%09%09%09%7D%0D%0A//%09%09%09%09%09System.out.println(args%5B0%5D);%0D%0A%09%09%09%09%09args%5B0%5D = args%5B0%5D.replace('%5Cufffd', '%5Cu00FC'); // wer auch immer die Testdaten gemacht hat: %22%5Cufffd%22? so kodiert man das ue doch nicht!%0D%0A//%09%09%09%09%09System.out.println(args%5B0%5D);%0D%0A
 %09%09%09%09%09list.ad
@@ -1827,25 +1827,8 @@
 );%0D%0A
-%09%09%09%09fr.close();%0D%0A
 %09%09%09%7D
@@ -1967,24 +1967,8 @@
 );%0D%0A
-%09%09%09fr.close();%0D%0A
 %09%09%7D 

replace malencoded characters in csvReader