PDF to byte array and vice versa

前端 未结 13 1247
独厮守ぢ
独厮守ぢ 2020-11-27 04:19

I need to convert pdf to byte array and vice versa.

Can any one help me?

This is how I am converting to byte array

public static byte[] conve         


        
13条回答
  •  囚心锁ツ
    2020-11-27 04:55

    PDFs may contain binary data and chances are it's getting mangled when you do ToString. It seems to me that you want this:

            FileInputStream inputStream = new FileInputStream(sourcePath);
    
            int numberBytes = inputStream .available();
            byte bytearray[] = new byte[numberBytes];
    
            inputStream .read(bytearray);
    

提交回复
热议问题