本文整理了Java中org.nutz.lang.Files.write()
方法的一些代码示例,展示了Files.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.write()
方法的具体详情如下:
包路径:org.nutz.lang.Files
类名称:Files
方法名:write
[英]将内容写到一个文件内,内容对象可以是:
代码示例来源:origin: nutzam/nutz
public void truncate(long len) throws SQLException {
Files.write(file, new Byte[]{});
}
代码示例来源:origin: nutzam/nutz
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);
}
}
}
代码示例来源:origin: nutzam/nutz
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();
}
}
代码示例来源:origin: nutzam/nutz
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);
}
代码示例来源:origin: nutzam/nutz
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);
}
代码示例来源:origin: nutzam/nutz
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);
}
}
代码示例来源:origin: nutzam/nutz
@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);
}
代码示例来源:origin: nutzam/nutz
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{
f = Jdbcs.getFilePool().createFile(".dat");
Files.write(f, in);
}
}
代码示例来源:origin: nutzam/nutz
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{
file = Jdbcs.getFilePool().createFile(".clob");
Files.write(file, in);
}
}
代码示例来源:origin: nutzam/nutz
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{
file = Jdbcs.getFilePool().createFile(".blob");
Files.write(file, in);
}
代码示例来源:origin: nutzam/nutz
/**
* 将内容写到一个文件内,内容对象可以是:
* <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);
}
}
代码示例来源:origin: nutzam/nutz
Files.write(tmp, img);
try {
return read(tmp);
代码示例来源:origin: org.nutz/nutz
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);
}
}
}
代码示例来源:origin: Rekoe/rk_svnadmin
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);
}
};
代码示例来源:origin: org.nutz/nutz
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);
}
代码示例来源:origin: org.nutz/nutz
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);
}
代码示例来源:origin: org.nutz/nutz
@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);
}
代码示例来源:origin: org.nutz/nutz
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{
f = Jdbcs.getFilePool().createFile(".dat");
Files.write(f, in);
}
}
代码示例来源:origin: org.nutz/nutz
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException{
file = Jdbcs.getFilePool().createFile(".clob");
Files.write(file, in);
}
}
代码示例来源:origin: nutzam/nutz-web
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!