首页
社区
课程
招聘
[求助]String fXML = getXml(fbyte);
发表于: 2017-11-10 21:38 2235

[求助]String fXML = getXml(fbyte);

2017-11-10 21:38
2235

public static void main(String[] args) throws Exception

  {

fname =“C:\\1.xml”;

byte[] fbyte = readFile(fname);

          String fXML = getXml(fbyte);

}


 public static byte[] readFile(String aFileName)

  {

    FileInputStream fio = null;

    byte[] abyte0 = (byte[])null;

    try

    {

      fio = new FileInputStream(aFileName);

      byte[] ftemp = new byte[8192];

      ByteArrayOutputStream fbyteout = new ByteArrayOutputStream(8192);

      int flen = 0;


      while (flen >= 0)

      {

        flen = fio.read(ftemp);

        if (flen > 0)

          fbyteout.write(ftemp, 0, flen);

      }

      ftemp = fbyteout.toByteArray();

      abyte0 = ftemp;

      if (fio != null)

        fio.close();

    } catch (Exception localException) {

    }

    return abyte0;

  }


public static String getXml(byte[] abytes)
{
if ((abytes == null) || (abytes.length <= 0))
return null;
byte[] ftemp = new byte[abytes.length];
for (int i = 0; i < ftemp.length; i++) {
ftemp[i] = ((byte)(abytes[i] ^ 0xFFFFFFFF));
}
EncodeBase64 fdecoder = new EncodeBase64();
String result = null;
try
{
result = new String(EncodeBase64.decode(new String(ftemp)), "UTF-8");
}
catch (Exception ex)
{
result = null;
}
return result;
}

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//