如何在flex中将pdf文件转换为字节数组,如何将字节数组检索为pdf文件?

如何在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;
  }