All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cc.youchain.utils.Files Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package cc.youchain.utils;

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

/**
 * File utility functions.
 */
public class Files {

    private Files() { }

    public static byte[] readBytes(File file) throws IOException {
        byte[] bytes = new byte[(int) file.length()];
        try (FileInputStream fileInputStream = new FileInputStream(file)) {
            fileInputStream.read(bytes);
        }
        return bytes;
    }

    public static String readString(File file) throws IOException {
        return new String(readBytes(file));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy