Writes the given byte array into a file. This function logs an error but doesn't throw if it fails. @param query The query being handled (for logging purposes). @param path The path to write to. @param contents The contents to write into the file.
(final HttpQuery query,
final String path,
final byte[] contents)
| 569 | * @param contents The contents to write into the file. |
| 570 | */ |
| 571 | private static void writeFile(final HttpQuery query, |
| 572 | final String path, |
| 573 | final byte[] contents) { |
| 574 | try { |
| 575 | final FileOutputStream out = new FileOutputStream(path); |
| 576 | try { |
| 577 | out.write(contents); |
| 578 | } finally { |
| 579 | out.close(); |
| 580 | } |
| 581 | } catch (FileNotFoundException e) { |
| 582 | logError(query, "Failed to create file " + path, e); |
| 583 | } catch (IOException e) { |
| 584 | logError(query, "Failed to write file " + path, e); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * Reads a file into a byte array. |