class 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 "";
    }

}