LogQueryService { public String downloadAtBase64(String name) { File file = asDownloadFile(name); try { RandomAccessFile raf = new RandomAccessFile(file, "r"); FileChannel channel = raf.getChannel(); ByteBuffer byteBuffer = ByteBuffer.allocate(1024); List<ChannelBuffer> list = new ArrayList<>(); while (channel.read(byteBuffer) != -1) { byteBuffer.flip(); byte[] array = byteBuffer.duplicate().array(); ChannelBuffer channelBuffer = ChannelBuffers.wrappedBuffer(array); list.add(channelBuffer); byteBuffer.clear(); } ChannelBuffer channelBuffer = ChannelBuffers.wrappedBuffer(list.toArray(new ChannelBuffer[]{})); ChannelBuffer encode = Base64.encode(channelBuffer); return new String(encode.array()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return ""; }  static List<String> toShowCols(String json); static List<Map<String, Object>> toTerms(String json); static LogQuery asLogQuery(Map<String, Object> parameterMap); static Long getQueryResultSize(int id); static Long getTotalSize(int id); static String getDownloadPath(int id); List<Map<String, Object>> getPaginate(int id, int page, int pageCount); List<LogQuery> getAll(); @Transactional boolean insert(LogQuery query); LogQuery getById(int id); @Transactional void delete(int id); List<Map<String, Object>> progress(); File asDownloadFile(String name); String downloadAtBase64(String name);  }
@Test public void testLogQueryService_downloadAtBase64() { String s = logQueryService.downloadAtBase64("events_query_1"); System.out.println(s); }