Skip to content

Commit

Permalink
Revert "fix qif export to SDCard" to fix codinguser#357.
Browse files Browse the repository at this point in the history
It's easier starting with this fix.
  • Loading branch information
rivaldi8 committed Nov 9, 2015
1 parent 6e0e853 commit 6818e45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
22 changes: 9 additions & 13 deletions app/src/main/java/org/gnucash/android/export/ExportAsyncTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -472,19 +472,15 @@ 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
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();
}
//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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,11 @@ public void generateExport(Writer writer) throws ExporterException {
* @throws IOException if something went wrong while splitting the file.
*/
public static List<String> splitQIF(File file) throws IOException {
return splitQIF(file, file);
}

public static List<String> splitQIF(File src, File dst) throws IOException {
// split only at the last dot
String[] pathParts = dst.getPath().split("(?=\\.[^\\.]+$)");
String[] pathParts = file.getPath().split("(?=\\.[^\\.]+$)");
ArrayList<String> splitFiles = new ArrayList<>();
String line;
BufferedReader in = new BufferedReader(new FileReader(src));
BufferedReader in = new BufferedReader(new FileReader(file));
BufferedWriter out = null;
try {
while ((line = in.readLine()) != null) {
Expand All @@ -250,7 +246,7 @@ public static List<String> splitQIF(File src, File dst) throws IOException {
out = new BufferedWriter(new FileWriter(newFileName));
} else {
if (out == null) {
throw new IllegalArgumentException(src.getPath() + " format is not correct");
throw new IllegalArgumentException(file.getPath() + " format is not correct");
}
out.append(line).append('\n');
}
Expand Down

0 comments on commit 6818e45

Please sign in to comment.