本文整理了Java中com.twelvemonkeys.io.FileUtil.write()
方法的一些代码示例,展示了FileUtil.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.write()
方法的具体详情如下:
包路径:com.twelvemonkeys.io.FileUtil
类名称:FileUtil
方法名:write
[英]Writes the contents from a byte array to a file.
[中]将字节数组中的内容写入文件。
代码示例来源:origin: haraldk/TwelveMonkeys
/**
* Writes the contents from a byte array to a file.
*
* @param pFilename The name of the file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(String pFilename, byte[] pData) throws IOException {
return write(new File(pFilename), pData);
}
代码示例来源:origin: haraldk/TwelveMonkeys
/**
* Writes the contents from a byte array to a file.
*
* @param pFile The file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(File pFile, byte[] pData) throws IOException {
boolean success = false;
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(pFile));
success = write(out, pData);
}
finally {
close(out);
}
return success;
}
代码示例来源:origin: haraldk/TwelveMonkeys
FileUtil.write(file1, data);
stream1.close();
FileUtil.write(file2, data);
stream2.close();
FileUtil.write(file3, data);
stream3.close();
代码示例来源:origin: haraldk/TwelveMonkeys
@Test
public void testSplit() throws IOException {
InputStream inputStream = getClassLoaderResource("/contrib/tiff/multipage.tif").openStream();
File inputFile = File.createTempFile("imageiotest", "tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
File outputDirectory = Files.createTempDirectory("imageio").toFile();
TIFFUtilities.split(inputFile, outputDirectory);
ImageReader reader = ImageIO.getImageReadersByFormatName("TIF").next();
File[] outputFiles = outputDirectory.listFiles();
Assert.assertEquals(3, outputFiles.length);
for (File outputFile : outputFiles) {
ImageInputStream iis = ImageIO.createImageInputStream(outputFile);
reader.setInput(iis);
Assert.assertEquals(1, reader.getNumImages(true));
iis.close();
outputFile.delete();
}
outputDirectory.delete();
inputFile.delete();
}
代码示例来源:origin: haraldk/TwelveMonkeys
@Test
public void testApplyOrientation() throws IOException {
InputStream inputStream = getClassLoaderResource("/contrib/tiff/multipage.tif").openStream();
File inputFile = File.createTempFile("imageiotest", "tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
BufferedImage image = ImageIO.read(inputFile);
// rotate by 90�
BufferedImage image90 = TIFFUtilities.applyOrientation(image, TIFFExtension.ORIENTATION_RIGHTTOP);
// rotate by 270�
BufferedImage image360 = TIFFUtilities.applyOrientation(image90, TIFFExtension.ORIENTATION_LEFTBOT);
byte[] original = ((DataBufferByte) image.getData().getDataBuffer()).getData();
byte[] rotated = ((DataBufferByte) image360.getData().getDataBuffer()).getData();
Assert.assertArrayEquals(original, rotated);
}
代码示例来源:origin: haraldk/TwelveMonkeys
File inputFile = File.createTempFile("imageiotest", ".tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-io
/**
* Writes the contents from a byte array to a file.
*
* @param pFilename The name of the file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(String pFilename, byte[] pData) throws IOException {
return write(new File(pFilename), pData);
}
代码示例来源:origin: com.twelvemonkeys/twelvemonkeys-core
/**
* Writes the contents from a byte array to a file.
*
* @param pFilename The name of the file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(String pFilename, byte[] pData) throws IOException {
return write(new File(pFilename), pData);
}
代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.common/common-io
/**
* Writes the contents from a byte array to a file.
*
* @param pFile The file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(File pFile, byte[] pData) throws IOException {
boolean success = false;
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(pFile));
success = write(out, pData);
}
finally {
close(out);
}
return success;
}
代码示例来源:origin: com.twelvemonkeys/twelvemonkeys-core
/**
* Writes the contents from a byte array to a file.
*
* @param pFile The file to write to
* @param pData The byte array to write
* @return {@code true}, otherwise an IOException is thrown.
* @throws IOException if an i/o error occurs during write.
*/
public static boolean write(File pFile, byte[] pData) throws IOException {
boolean success = false;
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(pFile));
success = write(out, pData);
}
finally {
close(out);
}
return success;
}
代码示例来源:origin: com.twelvemonkeys.contrib/contrib
@Test
public void testSplit() throws IOException {
InputStream inputStream = getClassLoaderResource("/contrib/tiff/multipage.tif").openStream();
File inputFile = File.createTempFile("imageiotest", "tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
File outputDirectory = Files.createTempDirectory("imageio").toFile();
TIFFUtilities.split(inputFile, outputDirectory);
ImageReader reader = ImageIO.getImageReadersByFormatName("TIF").next();
File[] outputFiles = outputDirectory.listFiles();
Assert.assertEquals(3, outputFiles.length);
for (File outputFile : outputFiles) {
ImageInputStream iis = ImageIO.createImageInputStream(outputFile);
reader.setInput(iis);
Assert.assertEquals(1, reader.getNumImages(true));
iis.close();
outputFile.delete();
}
outputDirectory.delete();
inputFile.delete();
}
代码示例来源:origin: com.twelvemonkeys.contrib/contrib
FileUtil.write(file1, data);
stream1.close();
FileUtil.write(file2, data);
stream2.close();
FileUtil.write(file3, data);
stream3.close();
代码示例来源:origin: com.twelvemonkeys.contrib/contrib
@Test
public void testApplyOrientation() throws IOException {
InputStream inputStream = getClassLoaderResource("/contrib/tiff/multipage.tif").openStream();
File inputFile = File.createTempFile("imageiotest", "tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
BufferedImage image = ImageIO.read(inputFile);
// rotate by 90�
BufferedImage image90 = TIFFUtilities.applyOrientation(image, TIFFExtension.ORIENTATION_RIGHTTOP);
// rotate by 270�
BufferedImage image360 = TIFFUtilities.applyOrientation(image90, TIFFExtension.ORIENTATION_LEFTBOT);
byte[] original = ((DataBufferByte) image.getData().getDataBuffer()).getData();
byte[] rotated = ((DataBufferByte) image360.getData().getDataBuffer()).getData();
Assert.assertArrayEquals(original, rotated);
}
代码示例来源:origin: com.twelvemonkeys.contrib/contrib
File inputFile = File.createTempFile("imageiotest", ".tif");
byte[] data = FileUtil.read(inputStream);
FileUtil.write(inputFile, data);
inputStream.close();
内容来源于网络,如有侵权,请联系作者删除!