/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.vutbr.feec.utko.fojtoval.krypto.funkce;

import cz.vutbr.feec.utko.fojtoval.krypto.windows.NavrhView;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Prace se souborem.
 * @author fojtoval
 */
public class FileMy {

    private static StringBuffer sb;
    private static FileReader fr;
    private static BufferedReader vstup;
    
    /**
     * Obsah textoveho souboru nacte do stringu.
     * @param s jmeno souboru
     * @return String s obsahem souboru
     */
    public static String nactiSoubor(String s){
        
        String vystup = "";
        try {
            fr = new FileReader(s);
            sb = new StringBuffer(1024);
            vstup = new BufferedReader(fr);
            char[] chars = new char[1024];
            int numRead = 0;
            try {
                vstup = new BufferedReader(new InputStreamReader(new FileInputStream(s),"windows-1250"));
                while ((numRead = vstup.read(chars)) > -1) {
                    sb.append(String.valueOf(chars, 0, numRead));
                }
            } catch (IOException ex) {
                Logger.getLogger(NavrhView.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            vystup = sb.toString();
                    
        } catch (FileNotFoundException ex) {
            Logger.getLogger(NavrhView.class.getName()).log(Level.SEVERE, null, ex);

          }
        return(vystup);
    }



}


