code.dreamsense.com

Reading a file in whole

import java.nio.file.*;

public class Test {
  public static void main(String[] args) throws Exception {
    String data = "";
    data = new String(Files.readAllBytes(Paths.get("Test.java")));
    System.out.println(data);
  }
}

Kyle Eggleston
kyle@dreamsense.com
Copyright © 2003 - 2020