Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. // Juggle the input file into a byte array for later extraction
  2. File sourceFile = new File(STRIPPED_DIR, STRIPPED_SOURCE);
  3. long fileSize = sourceFile.length();
  4. System.out.format("File size: %dn", fileSize);
  5. byte[] fileBytes = new byte[(int) fileSize];
  6. FileInputStream fis = new FileInputStream(sourceFile);
  7. int bytesRead = fis.read(fileBytes);
  8. fis.close();
  9. System.out.format("Bytes read: %dn", bytesRead);
  10. // Parse input file.
  11. ANTLRInputStream input = new ANTLRInputStream(new ByteArrayInputStream(fileBytes));
  12.  
  13. Dumper dumper = new Dumper(outWriter, usage, fileBytes);
  14. walker.walk(dumper, tree);
  15.  
  16. private String originalString(int from, int till) {
  17. return new String(fileBytes, from, till-from+1);
  18. }
  19.  
  20. private String originalString(ParserRuleContext ctx) {
  21. int from = ctx.start.getStartIndex();
  22. int till = ctx.stop.getStopIndex();
  23. return originalString(from, till);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement