Java – Read File to ByteArray

 

package com.pwn.nio;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class NIOReadFileToByteArray {

	public static void main(String[] args) {
		Path path = Paths.get("C:\\install\\instructions.txt");
		try {
			byte[] data = Files.readAllBytes(path);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s