Добавлен обработчик try/catch

This commit is contained in:
Victor 2013-12-02 15:30:46 +02:00
parent 72b797de7c
commit 9569b311b0
8 changed files with 29 additions and 18 deletions

View File

@ -9,6 +9,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import tse.Util;
/** /**
* *
@ -39,7 +40,7 @@ public class DirCopy extends AbstractFileChooser {
new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8") new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8")
); );
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -56,7 +57,7 @@ public class DirCopy extends AbstractFileChooser {
copyFile(file, dirDest); copyFile(file, dirDest);
writeLog(file.getAbsolutePath()); writeLog(file.getAbsolutePath());
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
} else writeLog("Нечего копировать из " + dirSource.getAbsolutePath()); } else writeLog("Нечего копировать из " + dirSource.getAbsolutePath());
@ -97,7 +98,9 @@ public class DirCopy extends AbstractFileChooser {
try { try {
writer.write(filename); writer.write(filename);
writer.newLine(); writer.newLine();
} catch (IOException ex) { } } catch (IOException ex) {
Util.handleException(ex);
}
} }
private final FileFilter lastModifiedFilter = new FileFilter() { private final FileFilter lastModifiedFilter = new FileFilter() {

View File

@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import tse.Util;
/** /**
* *
@ -43,7 +44,7 @@ public class DirFindText extends AbstractFileChooser {
new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8") new OutputStreamWriter(new FileOutputStream(logFile, true), "UTF-8")
); );
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -69,7 +70,9 @@ public class DirFindText extends AbstractFileChooser {
// Ищем строку в файле // Ищем строку в файле
try { try {
findString(file, SEARCH_TEXT); findString(file, SEARCH_TEXT);
} catch (IOException ex) {} } catch (IOException ex) {
Util.handleException(ex);
}
} }
} }
} }
@ -105,7 +108,9 @@ public class DirFindText extends AbstractFileChooser {
try { try {
writer.write(filename); writer.write(filename);
writer.newLine(); writer.newLine();
} catch (IOException ex) { } } catch (IOException ex) {
Util.handleException(ex);
}
} }
private class FindInfo { private class FindInfo {

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import tse.Util;
/** /**
* *
@ -48,7 +49,7 @@ public class DirZip extends AbstractFileChooser {
zos.close(); zos.close();
} }
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
System.out.println("Готово!"); System.out.println("Готово!");
} }

View File

@ -13,6 +13,7 @@ import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import tse.Util;
/** /**
* *
@ -79,7 +80,7 @@ public class LR_3_Tasks {
printList(ellipses); printList(ellipses);
System.out.println("Готово"); System.out.println("Готово");
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -106,7 +107,7 @@ public class LR_3_Tasks {
oos.close(); oos.close();
fos.close(); fos.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -119,7 +120,7 @@ public class LR_3_Tasks {
ois.close(); ois.close();
fis.close(); fis.close();
} catch (IOException | ClassNotFoundException ex) { } catch (IOException | ClassNotFoundException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
return object; return object;
} }

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import tse.Util;
/** /**
* Менеджер аккаунтов. * Менеджер аккаунтов.
@ -67,7 +68,7 @@ public class AccountManager {
oos.close(); oos.close();
fos.close(); fos.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -80,7 +81,7 @@ public class AccountManager {
ois.close(); ois.close();
fis.close(); fis.close();
} catch (IOException | ClassNotFoundException ex) { } catch (IOException | ClassNotFoundException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
return object; return object;
} }

View File

@ -11,6 +11,7 @@ import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import tse.Util;
/** /**
* Менеджер записей ежедневника. * Менеджер записей ежедневника.
@ -79,7 +80,7 @@ public class NotePadManager {
writer.flush(); writer.flush();
writer.close(); writer.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }
@ -103,7 +104,7 @@ public class NotePadManager {
reader.close(); reader.close();
return list; return list;
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
return null; return null;
} }

View File

@ -7,6 +7,7 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import tse.Util;
/** /**
* Чтение CSV файла. * Чтение CSV файла.
@ -63,7 +64,7 @@ public class CsvReader<T> {
obj = (T) handler.createObject(params); obj = (T) handler.createObject(params);
} }
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
if (obj != null) list.add(obj); if (obj != null) list.add(obj);
} }
@ -71,6 +72,4 @@ public class CsvReader<T> {
handler.onFinishRead(file); handler.onFinishRead(file);
return list; return list;
} }
} }

View File

@ -66,7 +66,7 @@ public class TrianglesWindow extends JFrame {
try { try {
csvReader.readCsv(); csvReader.readCsv();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); Util.handleException(ex);
} }
} }