要求:转换文件
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;
}
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)