diff --git a/app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java b/app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java index 94391f824..1f07600eb 100644 --- a/app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java +++ b/app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java @@ -472,15 +472,19 @@ private void shareFile(String path) { * @throws IOException if the file could not be copied */ public void copyFile(File src, File dst) throws IOException { - //TODO: Make this asynchronous at some time, t in the future. - FileChannel inChannel = new FileInputStream(src).getChannel(); - FileChannel outChannel = new FileOutputStream(dst).getChannel(); - try { - inChannel.transferTo(0, inChannel.size(), outChannel); - } finally { - if (inChannel != null) - inChannel.close(); - outChannel.close(); + //TODO: Make this asynchronous at some time, t in the future + if (mExportParams.getExportFormat() == ExportFormat.QIF) { + QifExporter.splitQIF(src, dst); + } else { + FileChannel inChannel = new FileInputStream(src).getChannel(); + FileChannel outChannel = new FileOutputStream(dst).getChannel(); + try { + inChannel.transferTo(0, inChannel.size(), outChannel); + } finally { + if (inChannel != null) + inChannel.close(); + outChannel.close(); + } } } diff --git a/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java b/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java index 27f362719..ac5ca01cc 100644 --- a/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java +++ b/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java @@ -230,11 +230,15 @@ public void generateExport(Writer writer) throws ExporterException { * @throws IOException if something went wrong while splitting the file. */ public static List splitQIF(File file) throws IOException { + return splitQIF(file, file); + } + + public static List splitQIF(File src, File dst) throws IOException { // split only at the last dot - String[] pathParts = file.getPath().split("(?=\\.[^\\.]+$)"); + String[] pathParts = dst.getPath().split("(?=\\.[^\\.]+$)"); ArrayList splitFiles = new ArrayList<>(); String line; - BufferedReader in = new BufferedReader(new FileReader(file)); + BufferedReader in = new BufferedReader(new FileReader(src)); BufferedWriter out = null; try { while ((line = in.readLine()) != null) { @@ -248,7 +252,7 @@ public static List splitQIF(File file) throws IOException { out = new BufferedWriter(new FileWriter(newFileName)); } else { if (out == null) { - throw new IllegalArgumentException(file.getPath() + " format is not correct"); + throw new IllegalArgumentException(src.getPath() + " format is not correct"); } out.append(line).append('\n'); }