Here you can find the source of getBytes(String outputFile, Map
public static byte[] getBytes(String outputFile, Map<String, String> queries)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.util.Map; public class Main { public static byte[] getBytes(String outputFile, Map<String, String> queries) { FileInputStream in = null; try {//from ww w .j a v a 2 s . c o m in = new FileInputStream(outputFile); ByteArrayOutputStream out = new ByteArrayOutputStream(); int c; byte buffer[] = new byte[1024]; while ((c = in.read(buffer)) != -1) { for (int i = 0; i < c; i++) out.write(buffer[i]); } out.close(); if (queries != null && queries.size() > 0) { String content = out.toString("utf-8"); for (String key : queries.keySet()) { content = content.replaceAll("%" + key + "%", queries.get(key)); } return content.getBytes("utf-8"); } return out.toByteArray(); } catch (Exception ex) { System.err.println(ex.getMessage()); return new byte[0]; } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } } }