Android Utililty Methods UTF8 File Read

List of utility methods to do UTF8 File Read

Description

The list of methods to do UTF8 File Read are organized into topic(s).

Method

StringloadUTF8(File file)
load UTF
FileInputStream is = new FileInputStream(file);
try {
    byte[] buf = new byte[1024];
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    while (true) {
        int read = is.read(buf);
        if (read == -1)
            break;
...
ListloadUTF8LinesFromFile(File file)
load UTF Lines From File
InputStream is = new FileInputStream(file);
Scanner scanner = new Scanner(is, "UTF-8");
List<String> r = new ArrayList<String>();
while (scanner.hasNextLine())
    r.add(scanner.nextLine());
is.close();
return r;
StringreadFile(String fileName, String encoding)
read File
try {
    File adfile = new File(fileName);
    StringBuffer content = new StringBuffer();
    if (adfile.isFile() && adfile.exists()) {
        InputStreamReader read = new InputStreamReader(
                new FileInputStream(adfile), encoding);
        BufferedReader in = new BufferedReader(read);
        String line1;
...
StringreadFromFile(String fileName)
reads the contents of the file passed in and returns the content as a String.
StringBuilder sb = new StringBuilder();
FileInputStream fstream = new FileInputStream(fileName);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in,
        "UTF-8"));
String line;
while ((line = br.readLine()) != null) {
    sb.append(line);
...