如何在flex中将pdf文件转换为字节数组,如何将字节数组检索为pdf文件? [英] How to convert pdf file into byte array,retrieve byte array into pdf file in flex?

查看:112
本文介绍了如何在flex中将pdf文件转换为字节数组,如何将字节数组检索为pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是flex的新手,我不知道将pdf文件转换为字节array.而且我也曾在google上尝试过,但没有结果.你能更喜欢如何在flex中将pdf文件转换为字节数组并将字节数组检索为pdf文件吗?应用程序.

紧急....

预先表示感谢.(没有什么不可能)

Hi ,
i am new to flex, i have no idea to convert pdf file into byte array.and also i tried in google also but no results yet.can u prefer how to convert pdf file into byte array and retrieve byte array into pdf file in flex application.

it is urgent....

Thanks in advance.(nothing is impossible)

推荐答案

您需要阅读PDF(文件阅读器),然后才能将该File-object转换为字节数组.这非常简单,因为任何对象都可以转换为字节数组.

在Java教程中读取,写入和创建文件 [
You need to read the PDF (filereader), then you can convert that File-object into a byte Array. That is pretty simple, because any object can be converted int a byte array.

Reading, Writing, and Creating Files @ Java Tutorials[^]


public static byte[] getBytes(Object obj) throws java.io.IOException{
      ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
      ObjectOutputStream oos = new ObjectOutputStream(bos); 
      oos.writeObject(obj);
      oos.flush(); 
      oos.close(); 
      bos.close();
      byte [] data = bos.toByteArray();
      return data;
  }


这篇关于如何在flex中将pdf文件转换为字节数组,如何将字节数组检索为pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆