diff options
author | David Luhmer <david-dev@live.de> | 2018-10-31 00:03:09 +0300 |
---|---|---|
committer | David Luhmer <david-dev@live.de> | 2018-10-31 00:03:09 +0300 |
commit | 7ed75f6a3ccf4a9483ef39af87daf742abd6ab80 (patch) | |
tree | 3e9782bc8c1775188193450355cf038a3c985b98 /News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java | |
parent | 353024b6c53dd6a20948823493c4fd4b6bd5ab61 (diff) |
refactoring
Diffstat (limited to 'News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java')
-rw-r--r-- | News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java deleted file mode 100644 index 78b6fc27..00000000 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/helper/FileUtils.java +++ /dev/null @@ -1,96 +0,0 @@ -/** -* Android ownCloud News -* -* @author David Luhmer -* @copyright 2013 David Luhmer david-dev@live.de -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ - -package de.luhmer.owncloudnewsreader.helper; - -import android.content.Context; -import android.os.Environment; - -import com.nostra13.universalimageloader.utils.StorageUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; - -import de.luhmer.owncloudnewsreader.services.PodcastDownloadService; - -public class FileUtils { - /** - * Creates the specified <code>toFile</code> as a byte for byte copy of the - * <code>fromFile</code>. If <code>toFile</code> already exists, then it - * will be replaced with a copy of <code>fromFile</code>. The name and path - * of <code>toFile</code> will be that of <code>toFile</code>.<br/> - * <br/> - * <i> Note: <code>fromFile</code> and <code>toFile</code> will be closed by - * this function.</i> - * - * @param fromFile - * - FileInputStream for the file to copy from. - * @param toFile - * - FileInputStream for the file to copy to. - */ - public static void copyFile(FileInputStream fromFile, FileOutputStream toFile) throws IOException { - FileChannel fromChannel = null; - FileChannel toChannel = null; - try { - fromChannel = fromFile.getChannel(); - toChannel = toFile.getChannel(); - fromChannel.transferTo(0, fromChannel.size(), toChannel); - } finally { - try { - if (fromChannel != null) { - fromChannel.close(); - } - } finally { - if (toChannel != null) { - toChannel.close(); - } - } - } - } - - public static String getPath(Context context) { - return StorageUtils.getCacheDirectory(context).getPath(); - } - - public static boolean DeletePodcastFile(Context context, String url) { - try { - File file = new File(PodcastDownloadService.getUrlToPodcastFile(context, url, false)); - if(file.exists()) - return file.delete(); - } catch (Exception ex) { - ex.printStackTrace(); - } - return false; - } - - public static String getPathPodcasts(Context context) - { - return getPath(context) + "/podcasts"; - } - - public static boolean isExternalStorageWritable() { - String state = Environment.getExternalStorageState(); - return Environment.MEDIA_MOUNTED.equals(state); - } -} |