Ejemplo n.º 1
0
 /**
  * Creates a temporary JSON file with the specified layout.
  *
  * @param desc Layout descriptor.
  * @return Temporary JSON file containing the specified layout.
  * @throws IOException on I/O error.
  */
 public static File getTempFile(TableLayoutDesc desc) throws IOException {
   final File layoutFile = File.createTempFile("layout-" + desc.getName(), "json");
   layoutFile.deleteOnExit();
   final OutputStream fos = new FileOutputStream(layoutFile);
   IOUtils.write(ToJson.toJsonString(desc), fos);
   ResourceUtils.closeOrLog(fos);
   return layoutFile;
 }
Ejemplo n.º 2
0
 /**
  * Writes a table layout as a JSON descriptor in a temporary file.
  *
  * @param layoutDesc Table layout descriptor to write.
  * @return the temporary File where the layout has been written.
  * @throws Exception on error.
  */
 private File getTempLayoutFile(TableLayoutDesc layoutDesc) throws Exception {
   final File layoutFile = File.createTempFile(layoutDesc.getName(), ".json", getLocalTempDir());
   final OutputStream fos = new FileOutputStream(layoutFile);
   try {
     IOUtils.write(ToJson.toJsonString(layoutDesc), fos);
   } finally {
     fos.close();
   }
   return layoutFile;
 }