public void truncate(long len) throws SQLException { Files.write(file, new Byte[]{}); }
public Class<?> define(String className, byte[] bytes, ClassLoader loader) { try { if (debugDir != null) Files.write(debugDir + className.replace('.', '/') + ".class", bytes); return ReflectTool.defineClass(className, bytes, loader); } catch (Exception e) { throw new RuntimeException(e); } } }
public static boolean copyOnWrite(File f, Object obj) { File tmp = new File(f.getAbsolutePath() + ".new"); File tmp2 = new File(f.getAbsolutePath() + ".old"); tmp2.delete(); try { write(tmp, obj); boolean flag = false; if (f.exists()) { flag = f.renameTo(tmp2); } if (tmp.renameTo(f)) { tmp2.delete(); return true; } else if (flag) tmp2.renameTo(f); // 如果这里也失败的话,起码.old还在... return false; } finally { tmp.delete(); } }
public Object get(ResultSet rs, int columnIndex) throws SQLException { Blob blob = rs.getBlob(columnIndex); if (blob == null) return null; File f = this.createTempFile(); Files.write(f, blob.getBinaryStream()); return new SimpleBlob(f); }
public Object get(ResultSet rs, String colName) throws SQLException { Blob blob = rs.getBlob(colName); if (blob == null) return null; File f = this.createTempFile(); Files.write(f, blob.getBinaryStream()); return new SimpleBlob(f); }
public Object get(ResultSet rs, String colName) throws SQLException { InputStream in = rs.getBinaryStream(colName); if (in == null) { return in; } try { File f = File.createTempFile("nutzdao_blob", ".tmp"); Files.write(f, in); in.close(); return new ReadOnceInputStream(f); } catch (IOException e) { throw Lang.wrapThrow(e); } }
@Override public Object get(ResultSet rs, String colName) throws SQLException { InputStream ins = rs.getBinaryStream(colName); if (ins == null) return null; File f = this.createTempFile(); Files.write(f, ins); return new SimpleBlob(f); }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{ f = Jdbcs.getFilePool().createFile(".dat"); Files.write(f, in); } }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{ file = Jdbcs.getFilePool().createFile(".clob"); Files.write(file, in); } }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{ file = Jdbcs.getFilePool().createFile(".blob"); Files.write(file, in); }
/** * 将内容写到一个文件内,内容对象可以是: * <ul> * <li>InputStream - 按二进制方式写入 * <li>byte[] - 按二进制方式写入 * <li>Reader - 按 UTF-8 方式写入 * <li>其他对象被 toString() 后按照 UTF-8 方式写入 * </ul> * * @param path * 文件路径,如果不存在,则创建 * @param obj * 内容对象 */ public static void write(String path, Object obj) { if (null == path || null == obj) return; try { write(Files.createFileIfNoExists(path), obj); } catch (IOException e) { throw Lang.wrapThrow(e); } }
Files.write(tmp, img); try { return read(tmp);
public Class<?> define(String className, byte[] bytes, ClassLoader loader) { try { if (debugDir != null) Files.write(debugDir + className.replace('.', '/') + ".class", bytes); return ReflectTool.defineClass(className, bytes, loader); } catch (Exception e) { throw new RuntimeException(e); } } }
public void visit(File file) { if (file.isDirectory()) return; System.out.println(file); String origin = Files.read(file); String output = origin.replaceAll("FZY4JW_0.ttf", "FZY4FZ_0.ttf"); if (origin.equals(output)) return; Files.write(file, output); } };
public Object get(ResultSet rs, int columnIndex) throws SQLException { Blob blob = rs.getBlob(columnIndex); if (blob == null) return null; File f = this.createTempFile(); Files.write(f, blob.getBinaryStream()); return new SimpleBlob(f); }
public Object get(ResultSet rs, String colName) throws SQLException { Blob blob = rs.getBlob(colName); if (blob == null) return null; File f = this.createTempFile(); Files.write(f, blob.getBinaryStream()); return new SimpleBlob(f); }
@Override public Object get(ResultSet rs, String colName) throws SQLException { InputStream ins = rs.getBinaryStream(colName); if (ins == null) return null; File f = this.createTempFile(); Files.write(f, ins); return new SimpleBlob(f); }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{ f = Jdbcs.getFilePool().createFile(".dat"); Files.write(f, in); } }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{ file = Jdbcs.getFilePool().createFile(".clob"); Files.write(file, in); } }
public void reset() { try { File f = Files.createFileIfNoExists(god_key_file_my); key = R.UU64(); Files.write(f, key + "\r\n"); } catch (IOException e) { throw Lang.wrapThrow(e); } }