Java Code Examples for org.apache.commons.io.FileUtils#writeByteArrayToFile()

The following examples show how to use org.apache.commons.io.FileUtils#writeByteArrayToFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractGraphicalContentProvider.java    From eclipsegraphviz with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * This default implementation relies on the
 * {@link #loadImage(Display, Point, Object)} method, subclasses are
 * encouraged to provide a more efficient implementation.
 */
public void saveImage(Display display, Point suggestedSize, Object input, IPath location, GraphicFileFormat fileFormat)
        throws CoreException {
	int swtFileFormat = getSWTFileFormat(fileFormat);
    Image toSave = loadImage(Display.getDefault(), new Point(0, 0), input);
    try {
        ImageLoader imageLoader = new ImageLoader();
        imageLoader.data = new ImageData[] { toSave.getImageData() };
        ByteArrayOutputStream buffer = new ByteArrayOutputStream(200 * 1024);
        imageLoader.save(buffer, swtFileFormat);
        try {
            FileUtils.writeByteArrayToFile(location.toFile(), buffer.toByteArray());
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error saving image", e));
        }
    } finally {
        toSave.dispose();
    }
}
 
Example 2
Source File: AbstractPlUmlEditor.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public boolean saveDocument() throws IOException {
  boolean result = false;
  if (this.title.isChanged()) {
    final TextFile textFile = this.currentTextFile.get();
    if (this.isOverwriteAllowed(textFile)) {
      File file = this.title.getAssociatedFile();
      if (file == null) {
        return this.saveDocumentAs();
      }

      final byte[] content = this.getEditorTextForSave().getBytes(StandardCharsets.UTF_8);
      FileUtils.writeByteArrayToFile(file, content);
      this.currentTextFile.set(new TextFile(file, false, content));
      this.title.setChanged(false);
      this.deleteBackup();
      result = true;
      startRenderScript();
    }
  } else {
    result = true;
  }
  return result;
}
 
Example 3
Source File: ImageResizingServiceUT.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
@Test
public void createThumbnail() throws IOException {
    File file = new File("src/test/resources/sample_images/sampleImage_800.jpg");
    assertNotNull(file);
    assertTrue(file.exists());

    byte[] thumbByteArray = imageResizingService.createThumbnail(FileUtils.readFileToByteArray(file));
    assertNotNull(thumbByteArray);

    File outputFile = createOutputFile(file);

    FileUtils.writeByteArrayToFile(outputFile, thumbByteArray);
    log.debug("written file to: {}", outputFile);
    assertTrue(outputFile.exists());

    BufferedImage bufferedImage = ImageIO.read(outputFile);
    assertEquals(THUMB_SIZE, bufferedImage.getWidth());
}
 
Example 4
Source File: AbstractRepositoryTests.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
protected void saveSettings(IFileStore dir, Properties settings) throws IOException, CoreException {
    ByteArrayOutputStream rendered = new ByteArrayOutputStream();
    settings.store(rendered, null);
    dir.mkdir(EFS.NONE, null);
    FileUtils.writeByteArrayToFile(new File(dir.toLocalFile(EFS.NONE, null), IRepository.MDD_PROPERTIES),
            rendered.toByteArray());
}
 
Example 5
Source File: TestInstrumentMojoTest.java    From coroutines with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void mustInstrumentClasses() throws Exception {
    byte[] classContent = readZipFromResource("NormalInvokeTest.zip").get("NormalInvokeTest.class");
    
    File testDir = null;
    try {
        // write out
        testDir = Files.createTempDirectory(getClass().getSimpleName()).toFile();
        File testClass = new File(testDir, "NormalInvokeTest.class");
        FileUtils.writeByteArrayToFile(testClass, classContent);
        
        // mock
        Mockito.when(mavenProject.getTestClasspathElements()).thenReturn(Collections.emptyList());
        Build build = Mockito.mock(Build.class);
        Mockito.when(mavenProject.getBuild()).thenReturn(build);
        Mockito.when(build.getTestOutputDirectory()).thenReturn(testDir.getAbsolutePath());
        
        // execute plugin
        fixture.execute();
        
        // read back in
        byte[] modifiedTestClassContent = FileUtils.readFileToByteArray(testClass);
        
        // test
        assertTrue(modifiedTestClassContent.length > classContent.length);
    } finally {
        if (testDir != null) {
            FileUtils.deleteDirectory(testDir);
        }
    }
}
 
Example 6
Source File: DbFileMngImpl.java    From Lottery with GNU General Public License v2.0 5 votes vote down vote up
public File retrieve(String name) throws IOException {
	// 此方法依赖于文件名是唯一的,否则有可能出现问题。
	String path = System.getProperty("java.io.tmpdir");
	File file = new File(path, name);
	file = UploadUtils.getUniqueFile(file);
	DbFile df = findById(name);
	FileUtils.writeByteArrayToFile(file, df.getContent());
	return file;
}
 
Example 7
Source File: XmlIngestionTest.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public void testXmlReIngestion() throws Exception {

        // Define the path for the test environment
        String filePath = "org/kuali/rice/kew/batch/data/widgetsTest.xml";
        File ingestedFile = new ClasspathOrFileResourceLoader().getResource(filePath).getFile();
        List<XmlDocCollection> collections = new ArrayList<XmlDocCollection>();
        XmlDocCollection fileDoc = new FileXmlDocCollection(ingestedFile);
        collections.add(fileDoc);
        // ingest the collection and save it to the database
        Collection<XmlDocCollection> ingestedXmlFile = null;
        try {
            ingestedXmlFile = CoreApiServiceLocator.getXmlIngesterService().ingest(collections);
        } catch (Exception e) {
            LOG.error("Error ingesting data", e);
            //throw new RuntimeException(e);
        }

        EdlExportDataSet dataSet = new EdlExportDataSet();

        //Cast this for now
        List<EDocLiteAssociation> edla = EdlServiceLocator.getEDocLiteService().getEDocLiteAssociations();     
        String style = null;
        for (EDocLiteAssociation edl : edla) {
            if (edl != null) {
                style = edl.getStyle();
                if ("widgetsTest".equals(style)) {
                    dataSet.getEdocLites().add(edl);
                }
            }
        }
        
        byte[] xmlBytes = CoreApiServiceLocator.getXmlExporterService().export(dataSet.createExportDataSet());
        // now export that xml into a file
        File reingestFile = File.createTempFile("widgetsTestOutput", ".xml");		
        FileUtils.writeByteArrayToFile(reingestFile, xmlBytes);
        String ingestedString = FileUtils.readFileToString(ingestedFile);
        String reingestedString = FileUtils.readFileToString(reingestFile);
        //assertTrue(FileUtils.contentEquals(ingestedFile, reingestFile));
    }
 
Example 8
Source File: AndroidDevice.java    From agent with MIT License 5 votes vote down vote up
@Override
public File stopRecordingScreen() throws IOException {
    if (canUseAppiumRecordVideo) {
        File videoFile = new File(UUIDUtil.getUUID() + ".mp4");
        String base64Video = ((AndroidDriver) driver).stopRecordingScreen();
        FileUtils.writeByteArrayToFile(videoFile, Base64.getDecoder().decode(base64Video), false);
        return videoFile;
    } else {
        return scrcpyVideoRecorder.stop();
    }
}
 
Example 9
Source File: CityManualPerformanceTester.java    From quick-csv-streamer with GNU General Public License v2.0 5 votes vote down vote up
private File prepareFile(int sizeMultiplier) throws Exception {
    InputStream is = getClass().getResourceAsStream("/cities-unix.txt");
    byte[] content = IOUtils.toByteArray(is);
    File result = File.createTempFile("csv", "large");
    for (int i = 0; i < sizeMultiplier; i++) {
        FileUtils.writeByteArrayToFile(result, content, true);
    }
    return result;
}
 
Example 10
Source File: WebPage.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
public File getRecording(String fileName) throws IOException {
  browser.executeScript("kurentoTest.recordingToData();");
  String recording = getProperty("recordingData").toString();

  // Base64 to File
  File outputFile = new File(fileName);
  byte[] bytes = Base64.decodeBase64(recording.substring(recording.lastIndexOf(",") + 1));
  FileUtils.writeByteArrayToFile(outputFile, bytes);

  return outputFile;
}
 
Example 11
Source File: DexProcessor.java    From DexExtractor with GNU General Public License v3.0 5 votes vote down vote up
public static boolean decodeDex(File dexFile) throws IOException {
	byte[] datas = FileUtils.readFileToByteArray(dexFile);
	byte[] dexData = Base64.decode(datas, Base64.DEFAULT);
	File readedDex = new File(dexFile.getAbsolutePath().replace(".dex", ".read.dex"));
	readedDex.delete();
	FileUtils.writeByteArrayToFile(readedDex, dexData);

	return true;
}
 
Example 12
Source File: SourceTextEditor.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean saveDocument() throws IOException {
  boolean result = false;

  final TextFile textFile = this.currentTextFile.get();
  final DialogProvider dialogProvider = DialogProviderManager.getInstance().getDialogProvider();

  if (this.title.isChanged()) {
    if (this.isOverwriteAllowed(textFile)) {
      File file = this.title.getAssociatedFile();
      if (file == null) {
        file = dialogProvider
                .msgSaveFileDialog(Main.getApplicationFrame(), "sources-editor", "Save sources", null, true, new FileFilter[]{getFileFilter()}, "Save");
        if (file == null) {
          return result;
        }
      }

      final String editorText = this.editor.getText();
      final byte[] content = editorText.getBytes(StandardCharsets.UTF_8);
      FileUtils.writeByteArrayToFile(file, content);
      this.currentTextFile.set(new TextFile(file, false, content));

      this.originalText = editorText;
      this.title.setChanged(false);
      this.deleteBackup();
      result = true;
    }
  } else {
    result = true;
  }
  return result;
}
 
Example 13
Source File: RunShaderFamily.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
public static ImageJobResult runShader(
    File outputDir,
    String shaderJobPrefix,
    IShaderDispatcher imageGenerator,
    Optional<ImageData> referenceImage)
    throws ShaderDispatchException, InterruptedException, IOException {

  final String shaderName = new File(shaderJobPrefix).getName();
  final File outputImage = new File(outputDir, shaderName + ".png");
  final File outputText = new File(outputDir, shaderName + ".txt");

  LOGGER.info("Shader set experiment: {} ", shaderJobPrefix);
  ImageJobResult res = imageGenerator.getImage(shaderJobPrefix, outputImage, false);

  if (res.isSetLog()) {
    FileUtils.writeStringToFile(outputText, res.getLog(), Charset.defaultCharset());
  }
  if (res.isSetPNG()) {
    FileUtils.writeByteArrayToFile(outputImage, res.getPNG());
  }

  // Create gif when there is two image files set. This may happen not only for NONDET state,
  // but also in case of Sanity error after a nondet.
  if (res.isSetPNG() && res.isSetPNG2()) {
    // we can dump both images
    File outputNondet1 = new File(outputDir, shaderName + "_nondet1.png");
    File outputNondet2 = new File(outputDir, shaderName + "_nondet2.png");
    FileUtils.writeByteArrayToFile(outputNondet1, res.getPNG());
    FileUtils.writeByteArrayToFile(outputNondet2, res.getPNG2());

    // Create gif
    try {
      BufferedImage nondetImg = ImageIO.read(
          Thread.currentThread().getContextClassLoader().getResourceAsStream("nondet.png"));
      BufferedImage img1 = ImageIO.read(
          new ByteArrayInputStream(res.getPNG()));
      BufferedImage img2 = ImageIO.read(
          new ByteArrayInputStream(res.getPNG2()));
      File gifFile = new File(outputDir,shaderName + ".gif");
      ImageOutputStream gifOutput = new FileImageOutputStream(gifFile);
      GifSequenceWriter gifWriter = new GifSequenceWriter(gifOutput, img1.getType(), 500, true);
      gifWriter.writeToSequence(nondetImg);
      gifWriter.writeToSequence(img1);
      gifWriter.writeToSequence(img2);
      gifWriter.close();
      gifOutput.close();
    } catch (Exception err) {
      LOGGER.error("Error while creating GIF for nondet");
      err.printStackTrace();
    }
  }

  // Dump job info in JSON
  File outputJson = new File(outputDir,shaderName + ".info.json");
  JsonObject infoJson = makeInfoJson(res, outputImage, referenceImage);
  FileUtils.writeStringToFile(outputJson,
      JsonHelper.jsonToString(infoJson), Charset.defaultCharset());

  return res;
}
 
Example 14
Source File: MainForm.java    From zxpoly with GNU General Public License v3.0 4 votes vote down vote up
private void menuFileFlushDiskChangesActionPerformed(ActionEvent evt) {
  for (int i = 0; i < 4; i++) {
    final TrDosDisk disk = this.board.getBetaDiskInterface().getDiskInDrive(i);
    if (disk != null && disk.isChanged()) {
      final int result = JOptionPane.showConfirmDialog(this,
          "Do you want flush disk data '" + disk.getSrcFile().getName() + "' ?", "Disk changed",
          JOptionPane.YES_NO_CANCEL_OPTION);
      if (result == JOptionPane.CANCEL_OPTION) {
        break;
      }
      if (result == JOptionPane.YES_OPTION) {
        final File destFile;
        if (disk.getType() != TrDosDisk.SourceDataType.TRD) {
          final JFileChooser fileChooser = new JFileChooser(disk.getSrcFile().getParentFile());
          fileChooser.setFileFilter(new TRDFileFilter());
          fileChooser.setAcceptAllFileFilterUsed(false);
          fileChooser.setDialogTitle("Save disk as TRD file");
          fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
          fileChooser.setSelectedFile(new File(disk.getSrcFile().getParentFile(),
              FilenameUtils.getBaseName(disk.getSrcFile().getName()) + ".trd"));
          if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
            destFile = fileChooser.getSelectedFile();
          } else {
            destFile = null;
          }
        } else {
          destFile = disk.getSrcFile();
        }
        if (destFile != null) {
          try {
            FileUtils.writeByteArrayToFile(destFile, disk.getDiskData());
            disk.replaceSrcFile(destFile, TrDosDisk.SourceDataType.TRD, true);
            LOGGER.info("Changes for disk " + ('A' + i) + " is saved as file: "
                + destFile.getAbsolutePath());
          } catch (IOException ex) {
            LOGGER.warning("Can't write disk for error: " + ex.getMessage());
            JOptionPane
                .showMessageDialog(this, "Can't save disk for IO error: " + ex.getMessage(),
                    "Error", JOptionPane.ERROR_MESSAGE);
          }
        }
      }
    }
  }
}
 
Example 15
Source File: MockDefinitionImportExportServiceTest.java    From smockin with Apache License 2.0 4 votes vote down vote up
private File unpackZipToTempArchive(final String base64EncodedZipFile) throws IOException {

        Assert.assertNotNull(base64EncodedZipFile);

        final byte[] zipFileBytes = Base64.getDecoder().decode(base64EncodedZipFile);
        final File unpackedDir = tempFolder.newFolder();
        final File zipFile = tempFolder.newFile("test_export.zip");

        FileUtils.writeByteArrayToFile(zipFile, zipFileBytes);

        Assert.assertNotNull(zipFile);

        GeneralUtils.unpackArchive(zipFile.getAbsolutePath(), unpackedDir.getAbsolutePath());

        return unpackedDir;
    }
 
Example 16
Source File: SsioIntegrationTest.java    From sep4j with Apache License 2.0 4 votes vote down vote up
@Test
public void saveTest_ValidAndInvalid() throws InvalidFormatException, IOException {
	LinkedHashMap<String, String> headerMap = new LinkedHashMap<String, String>();
	headerMap.put("primInt", "Primitive Int");
	headerMap.put("fake", "Not Real");

	ITRecord record = new ITRecord();
	record.setPrimInt(123);

	Collection<ITRecord> records = Arrays.asList(record);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	String datumErrPlaceholder = "!!ERROR!!";
	List<DatumError> datumErrors = new ArrayList<DatumError>();

	// save it
	Ssio.save(headerMap, records, outputStream, datumErrPlaceholder, datumErrors);
	byte[] spreadsheet = outputStream.toByteArray();

	// do a save for human eye check
	FileUtils.writeByteArrayToFile(createFile("saveTest_ValidAndInvalid"), spreadsheet);

	// then parse it
	Workbook workbook = WorkbookFactory.create(new ByteArrayInputStream(spreadsheet));

	/*** do assertions ***/
	Sheet sheet = workbook.getSheetAt(0);
	Row headerRow = sheet.getRow(0);
	Row dataRow = sheet.getRow(1);

	Cell cell00 = headerRow.getCell(0);
	Cell cell01 = headerRow.getCell(1);
	Cell cell10 = dataRow.getCell(0);
	Cell cell11 = dataRow.getCell(1);

	// size
	Assert.assertEquals(1, sheet.getLastRowNum());
	Assert.assertEquals(2, headerRow.getLastCellNum()); // note cell num is
														// 1-based
	Assert.assertEquals(2, dataRow.getLastCellNum());

	// types
	Assert.assertEquals(Cell.CELL_TYPE_STRING, cell00.getCellType());
	Assert.assertEquals(Cell.CELL_TYPE_STRING, cell01.getCellType());
	Assert.assertEquals(Cell.CELL_TYPE_STRING, cell10.getCellType());
	Assert.assertEquals(Cell.CELL_TYPE_STRING, cell11.getCellType());

	// texts
	Assert.assertEquals("Primitive Int", cell00.getStringCellValue());
	Assert.assertEquals("Not Real", cell01.getStringCellValue());
	Assert.assertEquals("123", cell10.getStringCellValue());
	Assert.assertEquals("!!ERROR!!", cell11.getStringCellValue());

	// errors
	DatumError datumError = datumErrors.get(0);
	Assert.assertEquals(1, datumErrors.size());
	Assert.assertEquals(0, datumError.getRecordIndex());
	Assert.assertEquals("fake", datumError.getPropName());
	Assert.assertTrue(datumError.getCause().getMessage().contains("no getter method"));

}
 
Example 17
Source File: ProjectContext.java    From gradle-plugins with MIT License 4 votes vote down vote up
public void writeOutputFile(String namespace, String filename, byte[] content) throws IOException {
	File file = buildFileFromParts(outputDir, namespace, filename);
	boolean mkdirs = file.getParentFile().exists() || file.getParentFile().mkdirs();
	if (!mkdirs) throw new IOException("Cannot create directory " + file.getParent());
	FileUtils.writeByteArrayToFile(file, content);
}
 
Example 18
Source File: SliceImageCmd.java    From zxpoly with GNU General Public License v3.0 4 votes vote down vote up
public void processScreen512x384(final File srcFile, final BufferedImage image)
    throws IOException {
  System.out.println("Slicing image for 512x384");

  final int pixelsNumber = 256 * 192;

  int[] imgBufCpu0 = new int[pixelsNumber];
  int[] imgBufCpu1 = new int[pixelsNumber];
  int[] imgBufCpu2 = new int[pixelsNumber];
  int[] imgBufCpu3 = new int[pixelsNumber];

  byte[] dataCpu0 = new byte[32 * 192];
  byte[] dataCpu1 = new byte[32 * 192];
  byte[] dataCpu2 = new byte[32 * 192];
  byte[] dataCpu3 = new byte[32 * 192];

  final int[] srcImageBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();

  byte[] attributesCpu0 = new byte[768];
  byte[] attributesCpu1 = new byte[768];
  byte[] attributesCpu2 = new byte[768];
  byte[] attributesCpu3 = new byte[768];

  int dstIndex = 0;
  for (int y = 0; y < 384; y += 2) {
    int yOffset = y * 512;

    for (int x = 0; x < 512; x += 2) {
      // CPU0
      imgBufCpu0[dstIndex] = srcImageBuffer[x + yOffset];

      // CPU1
      imgBufCpu1[dstIndex] = srcImageBuffer[x + yOffset + 1];

      // CPU2
      imgBufCpu2[dstIndex] = srcImageBuffer[x + yOffset + 512];

      // CPU3
      imgBufCpu3[dstIndex] = srcImageBuffer[x + yOffset + 512 + 1];

      dstIndex++;
    }
  }

  for (int li = 0; li < 768; li++) {
    attributesCpu0[li] = analyzeBlockForAttrib(li, imgBufCpu0, dataCpu0);
    attributesCpu1[li] = analyzeBlockForAttrib(li, imgBufCpu1, dataCpu1);
    attributesCpu2[li] = analyzeBlockForAttrib(li, imgBufCpu2, dataCpu2);
    attributesCpu3[li] = analyzeBlockForAttrib(li, imgBufCpu3, dataCpu3);
  }

  final File outFolder = srcFile.getParentFile();

  FileUtils.writeByteArrayToFile(
      new File(outFolder, FilenameUtils.getBaseName(srcFile.getName()) + "c0.c0"),
      packZxScreen(dataCpu0, attributesCpu0));
  FileUtils.writeByteArrayToFile(
      new File(outFolder, FilenameUtils.getBaseName(srcFile.getName()) + "c1.c1"),
      packZxScreen(dataCpu1, attributesCpu1));
  FileUtils.writeByteArrayToFile(
      new File(outFolder, FilenameUtils.getBaseName(srcFile.getName()) + "c2.c2"),
      packZxScreen(dataCpu2, attributesCpu2));
  FileUtils.writeByteArrayToFile(
      new File(outFolder, FilenameUtils.getBaseName(srcFile.getName()) + "c3.c3"),
      packZxScreen(dataCpu3, attributesCpu3));
}
 
Example 19
Source File: SystemCommonController.java    From base-framework with Apache License 2.0 4 votes vote down vote up
/**
 * 修改用户头像C
 * 
 * @param request HttpServletRequest
 * @throws IOException 
 */
@ResponseBody
@RequestMapping("/change-portrait")
public Map<String, Object> changePortrait(HttpServletRequest request) throws IOException {
	//获取当前用户
	User entity = SystemVariableUtils.getSessionVariable().getUser();
	
	Map<String, Object> result = Maps.newHashMap();
	
	//获取传进来的流
	InputStream is = request.getInputStream();
	//读取流内容到ByteArrayOutputStream中
	ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
	int ch;
	while ((ch = is.read()) != -1) {
		bytestream.write(ch);
	}
	
	bytestream.close();
	
	File uploadDirectory = new File(fileUploadPath);
	
	//如果没有创建上传文件夹就创建文件夹
	if (!uploadDirectory.exists() || !uploadDirectory.isDirectory()) {
		uploadDirectory.mkdirs();
	}
	
	entity.setPortrait(fileUploadPath + entity.getId());
	
	File portraitFile = new File(fileUploadPath + entity.getId());
	//如果当前用户没有创建头像,就创建头像
	if (!portraitFile.exists()) {
		portraitFile.createNewFile();
	}
	//拷贝到指定路径里
	FileUtils.writeByteArrayToFile(portraitFile, bytestream.toByteArray());
	accountManager.updateUser(entity);
	SystemVariableUtils.getSessionVariable().setUser(entity);
	//设置状态值,让FaustCplus再次触发jsfunc的js函数
	result.put("status","success");
	
	return result;
}
 
Example 20
Source File: ConfigChannelSaltManager.java    From uyuni with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Checks that the outFile is inside the channel directory and writes the contents to
 * it.
 *
 * @param content byte[] ConfigContent to be written
 * @param channelDir the channel directory
 * @param outFile the output file
 * @throws IllegalArgumentException if there is an attempt to write file outside channel
 * directory
 * @throws IOException if there is an error when writing on the disk
 */
private void writeBinaryFile(byte[] content, File channelDir, File outFile)  throws IOException {
    assertStateInOrgDir(channelDir, outFile);
    outFile.getParentFile().mkdirs();
    FileUtils.writeByteArrayToFile(outFile, content);

}