Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

public class Main {
    /**
     * 
     * @param data
     */
    private static String readFromFile(String filename) {
        File file = new File(filename);
        byte b[] = null;
        try {
            if (file.exists()) {
                b = new byte[(int) file.length()];
                InputStream fi = new FileInputStream(file);
                fi.read(b);
                fi.close();
            }
        } catch (Exception e) {
            return null;
        }

        if (null != b) {
            return new String(b);
        }
        return null;
    }
}