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

com.jtransc.util.JTranscFiles Maven / Gradle / Ivy

package com.jtransc.util;

import java.io.*;
import java.util.Arrays;

public class JTranscFiles {
	static public boolean write(File file, byte[] data) {
		try {
			FileOutputStream fos = new FileOutputStream(file);
			fos.write(data);
			fos.close();
			return true;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
	}

	static public byte[] read(File file) throws IOException {
		byte[] out = new byte[(int) file.length()];
		FileInputStream s = new FileInputStream(file);
		int readed = s.read(out);
		s.close();

		return (readed != out.length) ? Arrays.copyOf(out, readed) : out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy