Cześć,
Mam tabelę z 3 kolumnami typu String, String i Double. Dane do tabeli wczytywane są z pliku. Plik zawiera także datę więc chciałbym zamienić typ kolumny String na Date aby później wykonywać operacje na datach. Jakieś podpowiedzi? Dzięki z góry!
Fragmenty kodu:
definicja tabeli
public static String produkt[]= new String[50];
public static String data[]= new String[50];
public static Double cena[]= new Double[50];
public static String dane[][]= new String[50][3];
ładowanie danych z pliku do tabeli
public void setHScore(){
File oFile=new File("C:\\moje\\tabela2.txt");
FileInputStream fis=null;
BufferedInputStream bis=null;
DataInputStream dis=null;
int iIndex=0;
String koszt;
try{
fis=new FileInputStream(oFile);
bis=new BufferedInputStream(fis);
dis=new DataInputStream(bis);
while(dis.available()!=0){
produkt[iIndex]=dis.readLine();
data[iIndex]=dis.readLine();
koszt=dis.readLine();
cena[iIndex]=(Double) Double.parseDouble(koszt);
dane[iIndex]=new String[]{produkt[iIndex], data[iIndex], String.valueOf(cena[iIndex])};
iIndex++;
}
fis.close();
bis.close();
dis.close();
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}