小编mon*_*ika的帖子

非静态方法encode(byte [])不能从静态上下文引用

package com.cordys.report;

import java.io.FileInputStream; 

import org.apache.commons.codec.binary.Base64;


public class Encode {
public static String encodeFileStream(String filePath) //file path ex : C:\Program Files\Cordys\Web\reports\I0001180.pdf
{    
try {
   FileInputStream fin = new FileInputStream("E:/CSS Document/Test.pdf");
   StringBuffer sb=new StringBuffer();
   int lineLength = 72;
   byte[] buf = new byte[lineLength/4*3];
   while (true) {
     int len = fin.read(buf);
     if (len <= 0) {
      break;
     }
    sb.append(Base64.encode(buf));

   return sb.toString();
 }
 }
 catch(Exception e) {
   return e.getMessage();
 }
}



}
Run Code Online (Sandbox Code Playgroud)

java

3
推荐指数
1
解决办法
3734
查看次数

标签 统计

java ×1