I\'m using an API that requires a java.io.File as input, but I\'d like to just send the API a byte array. Is there a way to create a File object that will read from my byte
String strFilePath = "filePath";
byte[] writeBytes = ...;
try {
FileOutputStream fos = new FileOutputStream(strFilePath);
fos.write(byteArray);
fos.close();
} catch(FileNotFoundException ex) {
// handle FileNotFoundException here
} catch(IOException ioe) {
// handle IOException here
}
EDIT: Usually I am not a fan of just giving code, but this whole streaming stuff used to confuse me quite a bit, so here is a solution ;).
EDIT2: Ok, I just realized, that this is exactly, what the OP did NOT want to do. So this answer is not really useful...