@Test
public void testBasic64Code() throws Exception {
String strdata = new String("how are you".getBytes("UTF-8"));
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(strdata);
System.out.println(decodedBytes); }

1.转PDF test

public class Base64ConvertPDFTest {

  public static void main(String[] args) {
// TODO Auto-generated method stub try {
String encodedBytes = readFile("/home/wrightdeng/Desktop/test.txt", StandardCharsets.UTF_8); BASE64Decoder decoder = new BASE64Decoder();
byte[] decodedBytes;
decodedBytes = decoder.decodeBuffer(encodedBytes); File file = new File("/home/wrightdeng/Desktop/newfile.pdf");;
FileOutputStream fop = new FileOutputStream(file); fop.write(decodedBytes);
fop.flush();
fop.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} static String readFile(String path, Charset encoding) throws IOException
{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
} }

工具类:

 ***************************************************************************/

public class Base64ConverterUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(Base64ConverterUtils.class);

    public static void Base64Converter(String encodedBytes, String tempPath) {
// BASE64Decoder decoder = new BASE64Decoder(); LOGGER.info("The file temp saved in :"+tempPath);
byte[] decodedBytes;
try {
decodedBytes = Base64.getDecoder().decode(encodedBytes); // decoder.decodeBuffer(encodedBytes);
File file = new File(tempPath);
FileOutputStream fop = new FileOutputStream(file);
fop.write(decodedBytes);
fop.flush();
fop.close();
} catch (IOException e) {
LOGGER.error("write file to server occurred exception,the reason: "+e.getMessage());
e.printStackTrace();
}
}
}

字符串转码 将文本转为PDF的更多相关文章

  1. 使用OpenOffice.org将各类文档转为PDF

    http://blog.zhaojie.me/2010/05/convert-document-to-pdf-via-openoffice.html ————————————————————————— ...

  2. java转pdf(html转为pdf),解决中文乱码,标签不规范等问题

    第一步,下载jar包以及建对应的文件夹.注意pd4ml的jar要选择pro版本.然后建一个pd4fonts.properties 里面对应的字体. SimSun = simsun.ttf 前面为变量名 ...

  3. Java 字符串转码工具类

    StringConvertUtils.java package javax.utils; /** * 字符串转码工具类 * * @author Logan * @createDate 2019-04- ...

  4. Java 将Html转为PDF(二)

    前面介绍了如何通过插件的方式将Html文件转为PDF,该方法需要使用Spire.PDF for Java 3.6.6或者之后的新版本,可根据自己的系统选择不同插件来实现转换.本文提供另外一种转换方法, ...

  5. Java实现windows,linux服务器word,excel转为PDF;aspose-words,Documents4j

    Java实现windows,linux服务器word,excel转为PDF:aspose-words,Documents4j 一.通过aspose-words将word,Excel文档转为PDF 1. ...

  6. 办公利器!用Python快速将任意文件转为PDF

    痛点: 相信大家都会遇到一种场景.老师/上司要求你把某个文件转为pdf,并且是一批(不止一个,一个的话手动就可以搞定),并且这种是枯燥无聊的工作,既没有什么技术含量又累. 试想一下,如果我把这些文件放 ...

  7. 将doc文件批量转为pdf文件

    需要将不少doc文件转为pdf,WPS带有这种功能,但是鼠标点击次数太多以后整个人都变得很烦躁 用了一下午去搜这方面的工具软件,找到若干.有一些免费,有一些试用的,但总归就找到一个真正能用,虽说生成的 ...

  8. OpenOfice将offic转为pdf并且在web显示

    1.将office首先要安装OpenOfice,傻瓜式安装就好了,之后可以使用下列代码将word转为pdf.这个需要导入jodconverter-2.2.2里的 ja r包 import java.i ...

  9. 《Netty5.0架构剖析和源码解读》【PDF】下载

    <Netty5.0架构剖析和源码解读>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230062545 内容简介 Netty 是个异步的 ...

随机推荐

  1. bzoj3172: [Tjoi2013]单词 ac自动机

    某人读论文,一篇论文是由许多单词组成.但他发现一个单词会在论文中出现很多次,现在想知道每个单词分别在论文中出现多少次. Input 第一个一个整数N,表示有多少个单词,接下来N行每行一个单词.每个单词 ...

  2. 个人知识管理系统Version1.0开发记录(08)

    切入点 前面,我们已经搭建好了web端的一种基本结构,需要进一步定位的主要问题有三点: 1.界面的选择和确定,用extjs做的初步样式,进一步改动为jqueryUI/html,再进一步改变为HTML5 ...

  3. IOS-网络(AFNetworking)

    一.AFNetWorking基本使用 // // ViewController.m // IOS_0112_AFNetWorking // // Created by ma c on 16/2/11. ...

  4. POJ 2251 Dungeon Master bfs 难度:0

    http://poj.org/problem?id=2251 bfs,把两维换成三维,但是30*30*30=9e3的空间时间复杂度仍然足以承受 #include <cstdio> #inc ...

  5. Android 4.3发布 新增4大改变25日推送升级[附Android 4.3 工厂镜像]

    北京时间7月25日,谷歌举行发布会,正式发布了全新的Nexus 7平板电脑以及Android 4.3系统. 其中Android 4.3系统隶属于4.X果冻豆(Jelly Bean)系列,是目前最新的操 ...

  6. Alpha发布

    作业链接[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2283] 视频展示 链接[https://v.youku.com/v_show/ ...

  7. Alpha阶段第1周 Scrum立会报告+燃尽图 06

    作业要求与https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246相同 一.小组介绍 组长:刘莹莹 组员:朱珅莹 孙韦男 祝玮琦 王玉潘 周 ...

  8. SUSE Linux Enterprise Server设置IP地址、网关、DNS(转载)

      说明: ip:192.168.21.172 子网掩码:255.255.255.0 网关:192.168.21.2 dns:8.8.8.8 8.8.4.4 1.设置ip地址vi /etc/sysco ...

  9. Oracle联合查询

    select * from teacher--联合查询 --01.union (并集)select tno from teacher where tno>1080 union(select tn ...

  10. 51nod 算法马拉松4 B递归(YY)

    递归   基准时间限制:1 秒 空间限制:131072 KB 分值: 80 函数f(n,m) { 若n=1或m=1返回a[n][m]; 返回f(n-1,m)异或f(n,m-1); } 读入2<= ...