why i get ClassCastExcept ion in this function
Code:
private void write_to_file(String wplata_wyplata,double amount){
try{
BufferedReader in = new BufferedReader(new FileReader("konta//"+NumerKonta+".txt"));
String wczytane_dane="";
String line = in.readLine();
double sd= sr_dost;
Double a1 = new Double(sd);
while (line !=null) {
wczytane_dane+=line;
line = in.readLine();
wczytane_dane+="\n";
}
in.close();
String patternStr = "[0-9]{0,2}\\.{1}[0-9]{0,2}";
String replacementStr = a1.toString();;
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(wczytane_dane);
String output = matcher.replaceFirst(replacementStr);
BufferedWriter out = new BufferedWriter(new FileWriter("konta//"+NumerKonta+".txt"));
double a= amount;
Double a2 = new Double(amount);
Calendar calendar = new GregorianCalendar();
Date date = (Date)calendar.getTime();
DateFormat localFormat = DateFormat.getDateInstance();
output+='\n'+wplata_wyplata+" "+localFormat.format( date ).toString()+" "+a2.toString();
System.out.println(output);
//out.write(output);
out.close();
}catch (FileNotFoundException e) {
System.err.println("Nie ma takiego konta(File not found!)");
}catch (IOException e) {
System.err.println(e);
} catch (NumberFormatException e) {
System.out.println("NumberFormatException: " + e.getMessage());
}catch (Exception ex) {
ex.printStackTrace(); }
}
Comment