jodd.io.FileUtil.writeBytes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(306)

本文整理了Java中jodd.io.FileUtil.writeBytes()方法的一些代码示例,展示了FileUtil.writeBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.writeBytes()方法的具体详情如下:
包路径:jodd.io.FileUtil
类名称:FileUtil
方法名:writeBytes

FileUtil.writeBytes介绍

暂无

代码示例

代码示例来源:origin: oblac/jodd

/**
 * @see #writeBytes(File, byte[], int, int)
 */
public static void writeBytes(final File dest, final byte[] data) throws IOException {
  writeBytes(dest, data, ZERO, data.length);
}

代码示例来源:origin: oblac/jodd

/**
 * @see #writeBytes(File, byte[], int, int)
 */
public static void writeBytes(final String dest, final byte[] data, final int off, final int len) throws IOException {
  writeBytes(file(dest), data, off, len);
}

代码示例来源:origin: oblac/jodd

/**
 * @see #writeBytes(File, byte[])
 */
public static void writeBytes(final String dest, final byte[] data) throws IOException {
  writeBytes(file(dest), data);
}

代码示例来源:origin: oblac/jodd

private File file(String fileName, int size) throws IOException {
  byte[] bytes = new byte[size];
  for (int i = 0; i < size; i++) {
    bytes[i] = (byte) i;
  }
  File file = new File(tempFolder, fileName);
  file.deleteOnExit();
  FileUtil.writeBytes(file, bytes);
  return file;
}

代码示例来源:origin: oblac/jodd

/**
 * Writes file upload item to destination folder or to destination file.
 * Returns the destination file.
 */
public File write(File destination) throws IOException {
  if (destination.isDirectory()) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(destination,  data);
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination);
    }
  }
  return destination;
}

代码示例来源:origin: oblac/jodd

/**
 * Writes created class content to output folder for debugging purposes.
 */
protected void dumpClassInDebugFolder(final byte[] bytes) {
  File debugFolder = proxetta.getDebugFolder();
  if (debugFolder == null) {
    return;
  }
  if (!debugFolder.exists() || !debugFolder.isDirectory()) {
    log.warn("Invalid debug folder: " + debugFolder);
  }
  String fileName = proxyClassName;
  if (fileName == null) {
    fileName = "proxetta-" + System.currentTimeMillis();
  }
  fileName += ".class";
  File file = new File(debugFolder, fileName);
  try {
    FileUtil.writeBytes(file, bytes);
  } catch (IOException ioex) {
    log.warn("Error writing class as " + file, ioex);
  }
}

代码示例来源:origin: redisson/redisson

try {
  File tempFile = FileUtil.createTempFile();
  FileUtil.writeBytes(tempFile, (byte[])value);
  return tempFile;
} catch (IOException ioex) {

代码示例来源:origin: oblac/jodd

@Test
void testZipEmptyFolder() throws IOException {
  byte[] bytes = ZipBuilder
    .createZipInMemory()
    .addFolder("myEmptyFolder")
    .toBytes();
  File tempDir = FileUtil.createTempDirectory();
  tempDir.deleteOnExit();
  File zipFile = new File(tempDir, "test.zip");
  FileUtil.writeBytes(zipFile, bytes);
  // read zip
  List<String> entries = ZipUtil.listZip(zipFile);
  assertEquals(1, entries.size());
  assertEquals("myEmptyFolder/", entries.get(0));
}

代码示例来源:origin: oblac/jodd

@Test
void check_against_created_binary_file() throws Exception {
  final File input = FileUtil.createTempFile();
  // first bytes of a zip / jar file
  FileUtil.writeBytes(input, new byte[] {0x50, 0x4b, 0x03, 0x04, 0x14, 0x20, 0x08, 0x08, 0x08, 0x20, 0x09,
      0x76, 0x19, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 });
  final boolean actual = FileUtil.isBinary(input);
  // asserts
  assertEquals(true, actual);
}

代码示例来源:origin: oblac/jodd

FileUtil.writeBytes(zipFile, bytes);

代码示例来源:origin: oblac/jodd

try {
  File tempFile = FileUtil.createTempFile();
  FileUtil.writeBytes(tempFile, (byte[])value);
  return tempFile;
} catch (IOException ioex) {

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #writeBytes(File, byte[], int, int)
 */
public static void writeBytes(final File dest, final byte[] data) throws IOException {
  writeBytes(dest, data, ZERO, data.length);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #writeBytes(File, byte[], int, int)
 */
public static void writeBytes(final String dest, final byte[] data, final int off, final int len) throws IOException {
  writeBytes(file(dest), data, off, len);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #writeBytes(File, byte[])
 */
public static void writeBytes(final String dest, final byte[] data) throws IOException {
  writeBytes(file(dest), data);
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Writes file upload item to destination folder or to destination file.
 * Returns the destination file.
 */
public File write(File destination) throws IOException {
  if (destination.isDirectory()) {
    destination = new File(destination, this.header.getFileName());
  }
  if (data != null) {
    FileUtil.writeBytes(destination,  data);
  } else {
    if (tempFile != null) {
      FileUtil.move(tempFile, destination);
    }
  }
  return destination;
}

代码示例来源:origin: org.jodd/jodd-wot

/**
 * Writes created class content to output folder for debugging purposes.
 */
protected void dumpClass(byte[] bytes) {
  String debugFolder = proxetta.getDebugFolder();
  if (debugFolder == null) {
    return;
  }
  File folder = new File(debugFolder);
  if (!folder.exists()) {
    folder.mkdirs();
  }
  String fileName = proxyClassName;
  if (fileName == null) {
    fileName = "proxetta-" + System.currentTimeMillis();
  }
  fileName += ".class";
  File file = new File(folder, fileName);
  try {
    FileUtil.writeBytes(file, bytes);
  } catch (IOException ioex) {
    log.warn("Error dumping class", ioex);
  }
}

代码示例来源:origin: org.jodd/jodd-proxetta

/**
 * Writes created class content to output folder for debugging purposes.
 */
protected void dumpClassInDebugFolder(final byte[] bytes) {
  File debugFolder = proxetta.getDebugFolder();
  if (debugFolder == null) {
    return;
  }
  if (!debugFolder.exists() || !debugFolder.isDirectory()) {
    log.warn("Invalid debug folder: " + debugFolder);
  }
  String fileName = proxyClassName;
  if (fileName == null) {
    fileName = "proxetta-" + System.currentTimeMillis();
  }
  fileName += ".class";
  File file = new File(debugFolder, fileName);
  try {
    FileUtil.writeBytes(file, bytes);
  } catch (IOException ioex) {
    log.warn("Error writing class as " + file, ioex);
  }
}

代码示例来源:origin: org.jodd/jodd-bean

try {
  File tempFile = FileUtil.createTempFile();
  FileUtil.writeBytes(tempFile, (byte[])value);
  return tempFile;
} catch (IOException ioex) {

相关文章