public File operaFileData(String path, byte[] by)
{
{
FileOutputStream fileout = null;
String fileName = path + "baidu.apk";
File file = new File(fileName);
if (file.exists())
{
file.delete();
}
try
{
fileout = new FileOutputStream(file);
fileout.write(by, 0, by.length);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} finally
{
try
{
fileout.close();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return file;
}
}
{
{
FileOutputStream fileout = null;
String fileName = path + "baidu.apk";
File file = new File(fileName);
if (file.exists())
{
file.delete();
}
try
{
fileout = new FileOutputStream(file);
fileout.write(by, 0, by.length);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
} finally
{
try
{
fileout.close();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return file;
}
}
本文提供了一个使用Java进行文件操作的示例代码,演示了如何将字节数组写入到指定路径的文件中,并覆盖已存在的文件。

4675

被折叠的 条评论
为什么被折叠?



