当前位置: 首页>>代码示例>>Java>>正文


Java方法org.nutz.lang.Files.write代码示例

以下是Java方法org.nutz.lang.Files.write的代码示例。如果您正苦于以下问题:Java Files.write方法的具体用法?Java Files.write怎么用?Java Files.write使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在org.nutz.lang.Files的用法示例。

本文一共展示了Files.write的15个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doFile

import org.nutz.lang.Files; //导入方法依赖的package包/类
static void doFile(File f) {
    // 处理文件名
    String fnm = f.getName()
                  .replaceAll("_projectName_", np.getProjectName())
                  .replaceAll("_mainName_", np.getMainName());

    String rph = Files.renamePath(Disks.getRelativePath(tmplHome, f), fnm);
    log.infof(" + %s", rph);

    // 创建目标文件
    File fDest = Files.getFile(projectHome, rph);
    Files.createFileIfNoExists(fDest);

    // 处理文件的内容
    Segment seg = Segments.read(f);
    String str = seg.render(ctx).toString();
    Files.write(fDest, str);
}
 
开发者ID:zozoh,项目:nutz-origin,完整代码来源:ZOrigin.java


示例2: get

import org.nutz.lang.Files; //导入方法依赖的package包/类
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);
}
        }
 
开发者ID:cowthan,项目:JavaAyo,完整代码来源:Jdbcs.java


示例3: get

import org.nutz.lang.Files; //导入方法依赖的package包/类
public Object get(ResultSet rs, String colName) throws SQLException {
    File f = this.createTempFile();
    Blob blob = rs.getBlob(colName);
    if (blob == null)
        return null;
    Files.write(f, blob.getBinaryStream());
    return new SimpleBlob(f);
}
 
开发者ID:cowthan,项目:JavaAyo,完整代码来源:BlobValueAdaptor.java


示例4: gen

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public List<File> gen(Project project) throws IOException {
	Template t = TemplatesLoader.load("templates/pom.xml");
	t.binding("project", project);
	File pom = Files.createFileIfNoExists(project.getOutput() + "/pom.xml");
	Files.write(pom, t.render());
	return Lang.array2list(new File[] { pom });
}
 
开发者ID:Kerbores,项目:Nutz-matic,完整代码来源:MavenProjectGener.java


示例5: gen

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public List<File> gen(Project project) throws IOException {

	Template t = TemplatesLoader.load("templates/web.xml");
	t.binding("project", project);
	File webxml = Files.createFileIfNoExists(project.getOutput() + "/" + project.getName() + "/src/main/webapp/WEB-INF/web.xml");
	Files.write(webxml, t.render());
	return Lang.array2list(new File[] { webxml });
}
 
开发者ID:Kerbores,项目:Nutz-matic,完整代码来源:WebXmlGener.java


示例6: gen

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public List<File> gen(Project project) throws IOException {

	List<File> files = new ArrayList<File>();
	for (Table table : project.getTables()) {
		// domain
		Template t = TemplatesLoader.load("templates/src/main/java/club/zhcs/thunder/bean/Table.java");
		t.binding("project", project);
		t.binding("table", table);
		File domain = Files.createFileIfNoExists(project.getOutput() + "/" + project.getName() + "/src/main/java/" + project.getPackagePath() + "bean/" + table.getClassName()
				+ ".java");
		Files.write(domain, t.render());
		files.add(domain);

		// service
		t = TemplatesLoader.load("templates/src/main/java/club/zhcs/thunder/service/Service.java");
		t.binding("project", project);
		t.binding("table", table);
		File service = Files.createFileIfNoExists(project.getOutput() + "/" + project.getName() + "/src/main/java/" + project.getPackagePath() + "service/"
				+ table.getClassName()
				+ "Service.java");
		Files.write(service, t.render());
		files.add(service);

		// module
		t = TemplatesLoader.load("templates/src/main/java/club/zhcs/thunder/module/Module.java");
		t.binding("project", project);
		t.binding("table", table);
		File module = Files.createFileIfNoExists(project.getOutput() + "/" + project.getName() + "/src/main/java/" + project.getPackagePath() + "module/"
				+ table.getClassName()
				+ "Module.java");
		Files.write(module, t.render());
		files.add(module);
	}

	return files;
}
 
开发者ID:Kerbores,项目:Nutz-matic,完整代码来源:JavaCodeGener.java


示例7: gen

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public List<File> gen(Project project) throws IOException {

	Template t = TemplatesLoader.load("templates/src/main/resources/conf/config.properties");
	t.binding("db", project.getDb());
	File config = Files.createFileIfNoExists(project.getOutput() + "/" + project.getName() + "/src/main/resources/conf/config.properties");
	Files.write(config, t.render());
	return Lang.array2list(new File[] { config });
}
 
开发者ID:Kerbores,项目:Nutz-matic,完整代码来源:ConfigGener.java


示例8: doEclipseProject

import org.nutz.lang.Files; //导入方法依赖的package包/类
static void doEclipseProject(String nm) {
    File f = Files.getFile(tmplHome, nm);
    if (null == f) {
        log.warnf(" !!!ignore!!! eclipse: %s", nm);
        return;
    }
    log.infof(" + eclipse: %s", nm);
    String phDest = np.getProjectName() + "/" + nm;
    File fDest = Files.getFile(eclipseWorkspace, phDest);
    Files.createFileIfNoExists(fDest);

    Segment seg = Segments.read(f);
    Files.write(fDest, seg.render(ctx).toString());
}
 
开发者ID:zozoh,项目:nutz-origin,完整代码来源:ZOrigin.java


示例9: upload

import org.nutz.lang.Files; //导入方法依赖的package包/类
@At({"/up", "/up/?"})
@AdaptBy(type=VoidAdaptor.class)
public void upload(long sensor_id, @Attr(IotKeys.UID)long userId, HttpServletResponse resp, HttpServletRequest req) throws IOException {
	if (req.getHeader("Content-Length") == null) {
		badReq(resp, Iots.NEED_CONTENT_LENGTH);
		return;
	}
	if (req.getContentLength() < 1) {
		badReq(resp, Iots.EMTRY_BODY);
		return;
	}
	if (req.getContentLength() > 1024*1024) {
		badReq(resp, Iots.TOOBIG);
		return;
	}
	if (sensor_id > 0) { // 图片上传
		IotSensor sensor = dao.fetch(IotSensor.class, Cnd.where("id", "=", sensor_id).and(IotKeys.UID, "=", userId));
		if (sensor == null) {
			badReq(resp, Iots.NOTFOUND);
			return;
		}
		// 保存一下
		File tmp = File.createTempFile("iot", ".jpg");
		try {
			Files.write(tmp, req.getInputStream());
			BufferedImage image = Images.read(tmp);
			iotSensorService.saveImage(sensor, tmp, image.getWidth(), image.getHeight());
		} catch (Exception e) {
			log.info("bad image", e);
		} finally {
			tmp.delete();
		}
	} else {
		// 普通上传
		iotHttpCmdHandler.exec(resp.getWriter(), Streams.readAndClose(req.getReader()), iotSensorService, dao);
	}
}
 
开发者ID:wendal,项目:whale,完整代码来源:IotExchangeModule.java


示例10: save

import org.nutz.lang.Files; //导入方法依赖的package包/类
public void save(String openid, WxMedia media, File f) {
	File target = new File(mediaPath(openid, media.getId()));
	Files.makeDir(target.getParentFile());
	if (f != null) {
		Files.copy(f, target);
		media.setSize(f.length());
	} else {
		Files.write(target, media.getStream());
	}
	Json.toJsonFile(new File(target.getAbsolutePath() + ".info"), media);
	log.info("save to " + target);
}
 
开发者ID:amdiaosi,项目:nutzWx,完整代码来源:MediaService.java


示例11: saveImage

import org.nutz.lang.Files; //导入方法依赖的package包/类
public void saveImage(IotSensor sensor, InputStream in, int w, int h) throws IOException {
	IotImageHistory img = new IotImageHistory();
	img.setSensorId(sensor.getId());
	img.setWidth(w);
	img.setHeight(h);
	img.setTimestamp(new Date());
	partDao(sensor).insert(img);
	Files.write(String.format("%s/%s/%s", imagePath, sensor.getId(), img.getId()), in);
	sensor.setLastUpdateTime(new Date());
	partDao(sensor).update(sensor, "^(lastUpdateTime)$");
}
 
开发者ID:amdiaosi,项目:nutzWx,完整代码来源:IotSensorService.java


示例12: truncate

import org.nutz.lang.Files; //导入方法依赖的package包/类
public void truncate(long len) throws SQLException {
    Files.write(file, new Byte[]{});
}
 
开发者ID:cowthan,项目:JavaAyo,完整代码来源:SimpleBlob.java


示例13: read

import org.nutz.lang.Files; //导入方法依赖的package包/类
/**
 * 将一个图片文件读入内存
 * 
 * @param img
 *            图片文件
 * @return 图片对象
 */
public static BufferedImage read(Object img) {
    try {
        if (img instanceof CharSequence) {
            return ImageIO.read(Files.checkFile(img.toString()));
        }
        if (img instanceof File)
            return ImageIO.read((File) img);

        if (img instanceof URL)
            img = ((URL) img).openStream();

        if (img instanceof InputStream) {
            File tmp = File.createTempFile("nutz_img", ".jpg");
            Files.write(tmp, (InputStream) img);
            try {
                return read(tmp);
            }
            finally {
                tmp.delete();
            }
        }
        throw Lang.makeThrow("Unkown img info!! --> " + img);
    }
    catch (IOException e) {
        try {
            InputStream in = null;
            if (img instanceof File)
                in = new FileInputStream((File) img);
            else if (img instanceof URL)
                in = ((URL) img).openStream();
            else if (img instanceof InputStream)
                in = (InputStream) img;
            if (in != null)
                return readJpeg(in);
        }
        catch (IOException e2) {
            e2.fillInStackTrace();
        }
        return null;
        // throw Lang.wrapThrow(e);
    }
}
 
开发者ID:cowthan,项目:JavaAyo,完整代码来源:Images.java


示例14: write

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public void write(ZFile zf, InputStream ins) {
    File f = checkFile(zf);
    Files.write(f, ins);
}
 
开发者ID:nutzam,项目:nutz-vfs,完整代码来源:ZSimpleIO.java


示例15: writeString

import org.nutz.lang.Files; //导入方法依赖的package包/类
@Override
public void writeString(ZFile zf, Reader r) {
    File f = checkFile(zf);
    Files.write(f, r);
}
 
开发者ID:nutzam,项目:nutz-vfs,完整代码来源:ZSimpleIO.java



注:本文示例均筛选自Github平台上各路大神开发的开源项目,代码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。