Ejemplo n.º 1
0
 private static void delete(File file) {
   try {
     boolean deleted = file.delete();
     if (deleted) {
       logger.log("Deleted " + file.getAbsolutePath(), Log.DEBUGMSG);
     } else {
       logger.log("Error deleting " + file.getAbsolutePath(), Log.WARNINGS);
     }
   } catch (SecurityException e) {
     logger.log(e, "Error deleting " + file.getAbsolutePath(), Log.WARNINGS);
   }
 }
Ejemplo n.º 2
0
  public static String[] readFileGetUTF8(File file) {
    int encoding = GDTConstants.ZEICHENSATZ_IBM_CP_437;
    try {
      List<String> dataList = FileUtils.readLines(file, "cp437");
      String[] data = dataList.toArray(new String[] {});
      String usedEncoding =
          GDTSatzNachrichtHelper.getValueIfExists(
              GDTConstants.FELDKENNUNG_VERWENDETER_ZEICHENSATZ, data);
      if (usedEncoding == null) return data; // Not set return default encoding

      int usedEncodingInt = Integer.parseInt(usedEncoding);
      if (encoding == usedEncodingInt) return data; // Set, but default

      if (usedEncodingInt == GDTConstants.ZEICHENSATZ_7BIT) {
        return FileUtils.readLines(file, GDTConstants.ZEICHENSATZ_7BIT_CHARSET_STRING)
            .toArray(new String[] {});
      } else if (usedEncodingInt == GDTConstants.ZEICHENSATZ_ISO8859_1_ANSI_CP_1252) {
        return FileUtils.readLines(file, "Cp1252").toArray(new String[] {});
      }
    } catch (IOException e) {
      String message = "GDT: Ein-/Ausgabe Fehler beim Lesen von " + file.getAbsolutePath();
      Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, message, e);
      StatusManager.getManager().handle(status, StatusManager.SHOW);
      logger.log(e, message, Log.WARNINGS);
    }
    return null;
  }