Android DataOutputStream Write fileToSysout(File fileToOut, File fileIn)

Here you can find the source of fileToSysout(File fileToOut, File fileIn)

Description

file To Sysout

Declaration

public static void fileToSysout(File fileToOut, File fileIn) 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void fileToSysout(File fileToOut, File fileIn) {
        FileInputStream fs = null;
        FileOutputStream ofs = null;
        DataOutputStream os;//ww w.j av  a 2s.co  m
        InputStreamReader is;
        BufferedReader br;
        StringBuilder outputBuilder = new StringBuilder();

        try {
            fs = new FileInputStream(fileToOut);
            ofs = new FileOutputStream(fileIn);
            is = new InputStreamReader(fs);
            br = new BufferedReader(is);
            os = new DataOutputStream(ofs);

            String line = "";
            while ((line = br.readLine()) != null) {
                outputBuilder.append(line).append("\r\n");
            }
            os.write(outputBuilder.toString().getBytes());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.getMessage();
        } finally {
            try {
                ofs.close();
                fs.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}