package net.unternet.jc; import eve.sys.Vm; import java.io.*; public class File { public static String getString(String filename) { InputStream input = null; String contents = ""; byte[] buffer = new byte[4096]; int count = 0; while (filename.startsWith("/")) filename = filename.substring(1); System.err.println("trying to fetch \"" + filename + "\""); try { input = Vm.openResource(null, filename); } catch (Exception fatal) { System.err.println("Could not get " + filename + " contents: " + fatal); return null; } System.err.println("trying to read \"" + filename + "\""); try { while ((count = input.read(buffer)) > 0) { System.err.println("read " + count + " bytes into buffer"); contents += new String(buffer, 0, count); System.err.println("contents now " + contents.length() + " bytes long"); } } catch (Exception nonfatal) { System.err.println("error during file read: " + nonfatal); } System.err.println("returning contents with length: " + contents.length()); return contents; } public static void main(String[] args) { Vm.startEve(args); for (int i = 0; i < args.length; i++) { getString(args[i]); } Vm.exit(0); } }