open UTF Reader - Android File Input Output

Android examples for File Input Output:UTF File

Description

open UTF Reader

Demo Code

/**/*from  w w  w  .  j a v a  2s.co  m*/
 *******************************************************************************
 * Copyright (C) 2001-2015, International Business Machines Corporation and
 * others. All Rights Reserved.
 *******************************************************************************
 */
//package com.java2s;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import java.io.InputStreamReader;

public class Main {
    public static BufferedReader openUTF8Reader(String dir, String filename)
            throws IOException {
        return openReader(dir, filename, "UTF-8");
    }

    public static BufferedReader openReader(String dir, String filename,
            String encoding) throws IOException {
        File file = new File(dir + filename);
        return new BufferedReader(new InputStreamReader(
                new FileInputStream(file), encoding), 4 * 1024);
    }
}

Related Tutorials