Move the file-related helper methods to a FileUtils class.

This commit is contained in:
Reece H. Dunn
2013-09-17 12:37:54 +01:00
parent 8731c237af
commit bbad97c194
3 changed files with 82 additions and 50 deletions
@@ -73,21 +73,10 @@ public class CheckVoiceData extends Activity {
return true;
}
public static String readContent(InputStream stream) throws IOException {
ByteArrayOutputStream content = new ByteArrayOutputStream();
int c = stream.read();
while (c != -1)
{
content.write((byte)c);
c = stream.read();
}
return content.toString();
}
public static boolean canUpgradeResources(Context context) {
try {
final String version = readContent(context.getResources().openRawResource(R.raw.espeakdata_version));
final String installedVersion = readContent(new FileInputStream(new File(getDataPath(context), "version")));
final String version = FileUtils.read(context.getResources().openRawResource(R.raw.espeakdata_version));
final String installedVersion = FileUtils.read(new FileInputStream(new File(getDataPath(context), "version")));
return !version.equals(installedVersion);
} catch (Exception e) {
return false;