project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/Utils.java
author Xeli
Sun, 21 Aug 2011 16:25:18 +0200
branchhedgeroid
changeset 5621 ea796c83ea47
parent 5473 a68f900c4e8c
child 5663 b13d1897d06f
permissions -rw-r--r--
added licenses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     1
/*
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     3
 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     4
 *
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     8
 *
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    12
 * GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    13
 *
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    15
 * along with this program; if not, write to the Free Software
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    17
 */
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    18
ea796c83ea47 added licenses
Xeli
parents: 5473
diff changeset
    19
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    20
package org.hedgewars.mobile;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    21
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    22
import java.io.BufferedOutputStream;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    23
import java.io.File;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    24
import java.io.FileOutputStream;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    25
import java.io.IOException;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    26
import java.io.InputStream;
5473
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    27
import java.util.ArrayList;
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    28
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    29
import android.content.Context;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    30
import android.content.res.TypedArray;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    31
import android.widget.Toast;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    32
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    33
public class Utils {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    34
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    35
	
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    36
	/**
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    37
	 * get the path to which we should download all the data files
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    38
	 * @param c context 
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    39
	 * @return absolute path
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    40
	 */
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    41
	public static String getDownloadPath(Context c){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    42
		File f =  c.getExternalCacheDir();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    43
		if(f != null){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    44
			return f.getAbsolutePath() + "/Data/";
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    45
		}else{
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    46
			Toast.makeText(c, R.string.sdcard_not_mounted, Toast.LENGTH_LONG);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    47
			return null;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    48
		}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    49
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    50
	
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    51
	/**
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    52
	 * Get files from dirName, dir name is relative to {@link getDownloadPath}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    53
	 * @param dirName
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    54
	 * @param c context
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    55
	 * @return string of files
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    56
	 */
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    57
	public static String[] getFileNamesFromRelativeDir(Context c, String dirName){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    58
		String prefix = getDownloadPath(c);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    59
		File f = new File(prefix + dirName);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    60
		
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    61
		if(f.exists() && f.isDirectory()) return f.list();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    62
		else throw new IllegalArgumentException("File not a directory or doesn't exist dirName = " + f.getAbsolutePath());
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    63
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    64
	
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    65
	/**
5473
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    66
	 * Return a File array with all the files from dirName
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    67
	 * @param c
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    68
	 * @param dirName
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    69
	 * @return
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    70
	 */
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    71
	public static File[] getFilesFromRelativeDir(Context c, String dirName){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    72
		String prefix = getDownloadPath(c);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    73
		File f = new File(prefix + dirName);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    74
		
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    75
		if(f.exists() && f.isDirectory()) return f.listFiles();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    76
		else throw new IllegalArgumentException("File not a directory or doesn't exist dirName = " + f.getAbsolutePath());
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    77
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    78
	
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    79
	/**
5473
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    80
	 * Checks if this directory has a file with suffix suffix
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    81
	 * @param f - directory
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    82
	 * @return
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    83
	 */
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    84
	public static boolean hasFileWithSuffix(File f, String suffix){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    85
		if(f.isDirectory()){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    86
			for(String s : f.list()){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    87
				if(s.endsWith(suffix)) return true;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    88
			}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    89
			return false;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    90
		}else{
5428
5d0c5f7a9339 Fixed a small bug for when detecting Themes
Xeli
parents: 5414
diff changeset
    91
			return false;
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    92
		}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    93
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
    94
	
5473
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    95
	/**
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    96
	 * Gives back all dirs which contain a file with suffix fileSuffix
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    97
	 * @param c
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    98
	 * @param path
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
    99
	 * @param fileSuffix
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   100
	 * @return
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   101
	 */
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   102
	public static String[] getDirsWithFileSuffix(Context c, String path, String fileSuffix){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   103
		File[] files = getFilesFromRelativeDir(c,path);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   104
		String[] validFiles = new String[files.length];
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   105
		int validCounter = 0;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   106
		
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   107
		for(File f : files){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   108
			if(hasFileWithSuffix(f, fileSuffix)) validFiles[validCounter++] = f.getName();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   109
		}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   110
		String[] ret = new String[validCounter];
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   111
		System.arraycopy(validFiles, 0, ret, 0, validCounter);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   112
		return ret;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   113
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   114
	
5473
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   115
	/**
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   116
	 * Get all files from directory dir which have the given suffix
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   117
	 * @param c
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   118
	 * @param dir
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   119
	 * @param suffix
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   120
	 * @param removeSuffix
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   121
	 * @return
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   122
	 */
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   123
	public static ArrayList<String> getFilesFromDirWithSuffix(Context c, String dir, String suffix, boolean removeSuffix){
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   124
		String[] files = Utils.getFileNamesFromRelativeDir(c, dir);
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   125
		ArrayList<String> ret = new ArrayList<String>();
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   126
		for(String s : files){
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   127
			if(s.endsWith(suffix)){
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   128
				if(removeSuffix) ret.add(s.substring(0, s.length()-suffix.length()));
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   129
				else ret.add(s);
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   130
			}
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   131
		}
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   132
		return ret;
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   133
	}
a68f900c4e8c Utility functions which are context wide, mostly SD methods right now
Xeli
parents: 5428
diff changeset
   134
	
5414
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   135
    /**
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   136
     * Moves resources pointed to by sourceResId (from @res/raw/) to the app's private data directory
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   137
     * @param c
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   138
     * @param sourceResId
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   139
     * @param directory
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   140
     */
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   141
	public static void resRawToFilesDir(Context c, int sourceResId, String directory){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   142
		byte[] buffer = new byte[1024];
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   143
		InputStream bis = null;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   144
		BufferedOutputStream bos = null;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   145
		File schemesDirFile = new File(c.getFilesDir().getAbsolutePath() + '/' + directory);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   146
		schemesDirFile.mkdirs();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   147
		String schemesDirPath = schemesDirFile.getAbsolutePath() + '/';
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   148
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   149
		//Get an array with the resource files ID
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   150
		TypedArray ta = c.getResources().obtainTypedArray(sourceResId);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   151
		int[] resIds = new int[ta.length()];
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   152
		for(int i = 0; i < ta.length(); i++){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   153
			resIds[i] = ta.getResourceId(i, 0);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   154
		}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   155
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   156
		for(int id : resIds){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   157
			String fileName = c.getResources().getResourceEntryName(id);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   158
			File f = new File(schemesDirPath + fileName);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   159
			try {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   160
				if(!f.createNewFile()){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   161
					f.delete();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   162
					f.createNewFile();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   163
				}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   164
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   165
				bis = c.getResources().openRawResource(id);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   166
				bos = new BufferedOutputStream(new FileOutputStream(f), 1024);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   167
				int read = 0;
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   168
				while((read = bis.read(buffer)) != -1){
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   169
					bos.write(buffer, 0, read);
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   170
				}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   171
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   172
			} catch (IOException e) {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   173
				e.printStackTrace();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   174
			}finally{
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   175
				if(bis != null)
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   176
					try { 
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   177
						bis.close();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   178
					} catch (IOException e) {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   179
						e.printStackTrace();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   180
					}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   181
				if(bos != null)
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   182
					try {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   183
						bos.close();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   184
					} catch (IOException e) {
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   185
						e.printStackTrace();
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   186
					}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   187
			}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   188
		}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   189
	}
34663c4743f7 Added a utility class needed by the Downloaders
Xeli
parents:
diff changeset
   190
}