, String 。
/**
* String
*/
public static File getFileFromBytes(String name,String path) {
byte[] b=name.getBytes();
BufferedOutputStream stream = null;
File file = null;
try {
file = new File(path);
FileOutputStream fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(b);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return file;
}
byteデータはファイルとして保存されます.
/**
* byte
*/
public static File getFileFromBytes(byte[] b,String path) {
BufferedOutputStream stream = null;
File file = null;
try {
file = new File(path);
FileOutputStream fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(b);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return file;
}