My colleagues and I have an argument about how the method File.delete()works in Java.
In our code:
File outFile = new File("/dir/name.ext");
if(outFile.exists())
outFile.delete();
FileInputStream inStream = new FileInputStream(outFile);
WriteFile.writeFile(inStream);
I cannot include the whole method object writeFilehere for security reasons, but after creating the necessary database object, it performs the following action:
BufferedOutputStream out = null;
Object[] args = {"an_encrypted_data_clob_name_in_the_database"};
Class[] argTypes = {Class.forName("java.lang.String")};
Object result = WSCallHelper.jdbcCall(null, rs, "getCLOB", args, argTypes);
CLOB clob = (CLOB)result;
out = new BufferedOutputStream(clob.getAsciiOutputStream());
byte[] buffer = new byte[512];
int bytesRead = -1;
while((bytesRead = inStream.read(buffer)) > -1)
out.write(buffer, 0, bytesRead);
I know this is a bit unclear, but the general point is that it creates AsciiOutputStreamfor Clob(yes, it should be Clob) and writes it to an object inStreamthat is passed from the previous method.
, - File.delete();, , , . , , , , outFile, inStream outFile inStream .
, ? , delete() , File, .