java - non-static method encode(byte[]) cannot be referenced from a static context -
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(); } } }
as seen @ http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/base64.html
try base64.encodebase64()
instead.
Comments
Post a Comment