Java File to Reader newReader(File file, String encoding)

Here you can find the source of newReader(File file, String encoding)

Description

new Reader

License

Open Source License

Declaration

private static BufferedReader newReader(File file, String encoding) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Sonatype, Inc./*from ww  w .  j  a va 2  s  .  c  o m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 *   http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

import java.io.BufferedReader;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    private static BufferedReader newReader(File file, String encoding) throws IOException {
        if (encoding == null || encoding.length() <= 0) {
            return new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        }
        return new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
    }
}

Related

  1. newReader(File file)
  2. newReader(File file, String charset)
  3. newReader(File pathname)
  4. newReader(String value)
  5. openReader(File file)
  6. openReader(final String file, String charset)