mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-10 00:11:11 +00:00
FileUtils: Set the initial size of the ByteArrayOutputStream buffer.
This commit is contained in:
@@ -76,7 +76,7 @@ public class CheckVoiceData extends Activity {
|
||||
public static boolean canUpgradeResources(Context context) {
|
||||
try {
|
||||
final String version = FileUtils.read(context.getResources().openRawResource(R.raw.espeakdata_version));
|
||||
final String installedVersion = FileUtils.read(new FileInputStream(new File(getDataPath(context), "version")));
|
||||
final String installedVersion = FileUtils.read(new File(getDataPath(context), "version"));
|
||||
return !version.equals(installedVersion);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
||||
@@ -19,13 +19,22 @@ package com.reecedunn.espeak;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class FileUtils {
|
||||
public static String read(File file) throws IOException {
|
||||
return read(new FileInputStream(file), (int)file.length());
|
||||
}
|
||||
|
||||
public static String read(InputStream stream) throws IOException {
|
||||
ByteArrayOutputStream content = new ByteArrayOutputStream();
|
||||
return read(stream, stream.available());
|
||||
}
|
||||
|
||||
public static String read(InputStream stream, int length) throws IOException {
|
||||
ByteArrayOutputStream content = new ByteArrayOutputStream(length);
|
||||
int c = stream.read();
|
||||
while (c != -1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user