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


Java FileUtil.writeString方法代码示例

本文整理汇总了Java中jodd.io.FileUtil.writeString方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.writeString方法的具体用法?Java FileUtil.writeString怎么用?Java FileUtil.writeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jodd.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.writeString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeJavaFile

import jodd.io.FileUtil; //导入方法依赖的package包/类
public void writeJavaFile() {
	try {
		String pkg2 = pkg + ".actions";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("import okhttp3.HttpUrl;\n" +
				"import org.datasays.wes.core.RequestInfo;\n" +
				"import org.datasays.wes.types.*;\n");
		javaCodes.append(codes.toString());
		javaCodes.append("}\n");
		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + clsName + ".java", javaCodes.toString(), "utf-8");
		codes = new StringBuilder();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DataSays,项目名称:wES,代码行数:20,代码来源:EsRestSpecGen.java

示例2: writeToFile

import jodd.io.FileUtil; //导入方法依赖的package包/类
public void writeToFile(String file) {
	StringBuilder javaCodes = new StringBuilder();
	javaCodes.append("package org.datasays.wes.client;\n\n");

	javaCodes.append("import retrofit2.Call;\n");
	javaCodes.append("import retrofit2.http.Body;\n");
	javaCodes.append("import retrofit2.http.DELETE;\n");
	javaCodes.append("import retrofit2.http.GET;\n");
	javaCodes.append("import retrofit2.http.HEAD;\n");
	javaCodes.append("import retrofit2.http.POST;\n");
	javaCodes.append("import retrofit2.http.PUT;\n");
	javaCodes.append("import retrofit2.http.Path;\n\n");

	javaCodes.append("public interface EsService {\n");
	javaCodes.append("	" + codes.toString() + "\n");

	javaCodes.append("}\n");
	try {
		FileUtil.writeString(file, javaCodes.toString(), "utf-8");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DataSays,项目名称:wES,代码行数:24,代码来源:EsRestSpecGen4Retrofit.java

示例3: execute

import jodd.io.FileUtil; //导入方法依赖的package包/类
@Override
public Void execute() throws Exception {
	HttpResponse lHttpResponse = HttpRequest.get(mStrDownloadUrl).send();
	if (lHttpResponse.statusCode() != 200) { // HTTP_OK = 200
		throw new HttpException(String.format("Unwanted http status %d from URL: %s", lHttpResponse.statusCode(), mStrDownloadUrl));
	}
	// Save xml file info to database.
	RepoXmlFile lRepoXmlFile = new RepoXmlFile.Builder()
			.idRepoXml(mRepoXml.getId())
			.fileName(mStrFileNameNew)
			.url(mStrDownloadUrl)
			.build();
	mRepoXmlFileDao.insert(lRepoXmlFile);
	// Save xml file to local storage.
	File lFileXml = new File(ConfigurationUtil.getXmlRepositoryDir(mRepoXml.getName()),
			File.separator + lRepoXmlFile.getFileName());
	FileUtil.writeString(lFileXml, lHttpResponse.bodyText());
	return null;
}
 
开发者ID:oing9179,项目名称:AndroidSDKLiteServer,代码行数:20,代码来源:DownloadRepoCommonXmlCommand.java

示例4: exportVcf

import jodd.io.FileUtil; //导入方法依赖的package包/类
public static void exportVcf(List<VcfBean> beans, File vcfFile) {
	try {
		StringBuffer sb = new StringBuffer();
		for (VcfBean bean : beans) {
			sb.append("BEGIN:VCARD\r\n");
			sb.append("VERSION:3.0\r\n");
			sb.append("N;CHARSET=UTF-8:;‭‬‭‬‭" + bean.getFullName() + ";;;\r\n");
			sb.append("FN;CHARSET=UTF-8: ‭‬‭‬‭" + bean.getFullName() + "\r\n");
			if ("" != bean.getOrg() && bean.getOrg() != null) {
				sb.append("ORG:" + bean.getOrg() + "\r\n");
			}
			if ("" != bean.getTitle() && bean.getTitle() != null) {
				sb.append("TITLE:" + bean.getTitle() + "\r\n");
			}
			if ("" != bean.getAddress() && bean.getAddress() != null) {
				sb.append("ADR;HOME:;;;" + bean.getAddress() + ";;;\r\n");
			}
			if ("" != bean.getNote() && bean.getNote() != null) {
				sb.append("NOTE:" + bean.getNote() + "\r\n");
			}
			if ("" != bean.getMobile() && bean.getMobile() != null) {
				sb.append("TEL;CELL:" + bean.getMobile() + "\r\n");
			}

			if ("" != bean.getTelePhone() && bean.getTelePhone() != null) {
				sb.append("TEL;HOME:" + bean.getTelePhone() + "\r\n");
			}
			if ("" != bean.getEmail() && bean.getEmail() != null) {
				sb.append("EMAIL:" + bean.getEmail() + "\r\n");
			}
			sb.append("END:VCARD\r\n");
		}
		FileUtil.writeString(vcfFile, sb.toString(), "utf-8");
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:DataAgg,项目名称:DAFramework,代码行数:38,代码来源:VcfUtils.java

示例5: writeJson

import jodd.io.FileUtil; //导入方法依赖的package包/类
public static void writeJson(String file, Object obj) {
	try {
		FileUtil.writeString(file, getGsonBuilder().create().toJson(obj), "utf-8");
	} catch (IOException e) {
		LOG.error(e.getMessage(), e);
	}
}
 
开发者ID:DataAgg,项目名称:DAFramework,代码行数:8,代码来源:WJsonUtils.java

示例6: writeEnumType

import jodd.io.FileUtil; //导入方法依赖的package包/类
public void writeEnumType(String type, List<String> options, String defaultValue, String description) {
	try {
		String pkg2 = pkg + ".types";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("//" + description + "\n");
		javaCodes.append("//default: " + defaultValue + "\n");
		javaCodes.append("public enum " + type + " {\n");
		String enumCodes = "";
		for (String option : options) {
			String enumName = option.toUpperCase();
			if (option.trim().length() <= 0) {
				enumName = "v";
			}
			enumCodes += "\t" + enumName + "(\"" + option + "\"),\n";
		}
		enumCodes = StringUtil.cutSuffix(enumCodes, ",\n");
		javaCodes.append(enumCodes + ";\n");

		javaCodes.append("\tprivate String name;\n");
		javaCodes.append("\t" + type + "(String name) {\n");
		javaCodes.append("\t\tthis.name = name;\n");
		javaCodes.append("\t}\n\n");
		javaCodes.append("\[email protected]\n");
		javaCodes.append("\tpublic String toString() {\n");
		javaCodes.append("\treturn this.name;\n");
		javaCodes.append("\t}\n");
		javaCodes.append("}");
		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + type + ".java", javaCodes.toString(), "utf-8");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DataSays,项目名称:wES,代码行数:37,代码来源:EsRestSpecGen.java

示例7: writeEsHelper

import jodd.io.FileUtil; //导入方法依赖的package包/类
public void writeEsHelper() {
	try {
		String pkg2 = pkg + ".client";
		StringBuilder javaCodes = new StringBuilder();
		javaCodes.append("package " + pkg2 + ";\n\n");

		javaCodes.append("import okhttp3.HttpUrl;\n");
		javaCodes.append("import okhttp3.OkHttpClient;\n");
		javaCodes.append("import org.datasays.wes.actions.*;\n");
		javaCodes.append("import org.datasays.wes.core.IConvert;\n");
		javaCodes.append("import org.datasays.wes.core.WHttpClient;\n\n");

		javaCodes.append("public class EsHelper extends WHttpClient {\n");
		javaCodes.append("\tprotected HttpUrl server;\n");
		javaCodes.append("\n");
		javaCodes.append("\tpublic EsHelper() {\n");
		javaCodes.append("\t\tsuper();\n");
		javaCodes.append("\t}\n\n");
		javaCodes.append("\tpublic void init(String server, OkHttpClient client, IConvert convert) {\n");
		javaCodes.append("\t\tif (server.trim().endsWith(\"/\")) {\n");
		javaCodes.append("\t\t\tserver = server.trim().substring(0, server.trim().length() - 1);\n");
		javaCodes.append("\t\t}\n");
		javaCodes.append("\t\tthis.server = HttpUrl.parse(server);\n");
		javaCodes.append("\t\tsuper.init(client, convert);\n");
		javaCodes.append("\t}\n\n");

		javaCodes.append(helperCodes.toString());

		javaCodes.append("}\n");

		String filePath = sourceDir + pkg2.replace('.', File.separatorChar) + File.separatorChar;
		FileUtil.mkdirs(filePath);
		FileUtil.writeString(filePath + "EsHelper.java", javaCodes.toString(), "utf-8");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DataSays,项目名称:wES,代码行数:38,代码来源:EsRestSpecGen.java

示例8: execute

import jodd.io.FileUtil; //导入方法依赖的package包/类
@Override
public Void execute() throws Exception {
	HttpResponse lHttpResponse = HttpRequest.get(mStrDownloadUrl).send();
	if (lHttpResponse.statusCode() != 200) { // HTTP_OK = 200
		throw new HttpException(String.format("Unwanted http status %d from URL: %s", lHttpResponse.statusCode(), mStrDownloadUrl));
	}
	// Save xml file info to database.
	RepoXmlFile lRepoXmlFile = new RepoXmlFile.Builder()
			.idRepoXml(mRepoXml.getId())
			.fileName(UrlTextUtil.getFileName(mStrDownloadUrl))
			.url(mStrDownloadUrl)
			.build();
	mRepoXmlFileDao.insert(lRepoXmlFile);
	// Save xml file to local storage.
	File lFileXml = new File(ConfigurationUtil.getXmlRepositoryDir(mRepoXml.getName()),
			File.separator + lRepoXmlFile.getFileName());
	FileUtil.writeString(lFileXml, lHttpResponse.bodyText());
	// Parse xml
	IRepoSitesEditor lEditor;
	{
		InputStream inputStream = IOUtils.toInputStream(lHttpResponse.bodyText(), "UTF-8");
		lEditor = RepoXmlEditorFactory.createRepoSitesEditor(mStrDownloadUrl, inputStream);
		IOUtils.closeQuietly(inputStream);
	}
	List<RepoSite> lListRepoSites = lEditor.extractAll();
	for (int i = 0, length = lListRepoSites.size(); i < length; i++) {
		RepoSite lRepoSite = lListRepoSites.get(i);
		String lStrFileName = UrlTextUtil.getFileName(lRepoSite.getUrl());
		// Avoid file name conflict by perform string formatting, an example after string formatting "addon2-1-x86_2.xml".
		lStrFileName = String.format("%s_%d.%s",
				lStrFileName.substring(0, lStrFileName.indexOf('.')),
				i,
				lStrFileName.substring(lStrFileName.lastIndexOf('.') + 1)
		);
		mListCommands.add(new DownloadRepoCommonXmlCommand(mRepoXmlFileDao, mRepoXml, lRepoSite.getAbsoluteUrl(), lStrFileName));
		lRepoSite.setUrl(lStrFileName);
	}
	// Commit changes back to xml file itself.
	lEditor.rebuild(lListRepoSites);
	{
		OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(lFileXml));
		lEditor.write(outputStream);
		IOUtils.closeQuietly(outputStream);
	}
	return null;
}
 
开发者ID:oing9179,项目名称:AndroidSDKLiteServer,代码行数:47,代码来源:DownloadRepoSitesXmlCommand.java


注:本文中的jodd.io.FileUtil.writeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。