本文整理汇总了Java中jodd.io.FileUtil类的典型用法代码示例。如果您正苦于以下问题:Java FileUtil类的具体用法?Java FileUtil怎么用?Java FileUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileUtil类属于jodd.io包,在下文中一共展示了FileUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import jodd.io.FileUtil; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// read some text from the file
String storyText = FileUtil.readString("data/story.txt");
StoryParser storyParser = new StoryParser();
Story story = storyParser.parseText(storyText);
// run me
AnswerFinder answerFinder = new AnswerFinder(storyParser);
Scanner reader = new Scanner(System.in);
while (true) {
System.out.println(">> ");
String input = reader.nextLine().trim().toLowerCase();
if (input.equals("exit")) {
System.out.println("Bye!");
break;
}
answerFinder.answer(story, input);
}
}
开发者ID:igr,项目名称:parlo,代码行数:25,代码来源:Parlo.java
示例2: mklink
import jodd.io.FileUtil; //导入依赖的package包/类
public static void mklink(String target, String source) throws Exception {
File fTarget = new File(polishFilePath(target));
if (fTarget.exists() && fTarget.isDirectory()) {
if (isSymbolicLink(target)) {
exec("rd /q " + fTarget.getAbsolutePath(), ".", true, true);
} else {
FileUtil.deleteDir(fTarget);
}
}
if (!fTarget.getParentFile().exists()) {
FileUtil.mkdirs(fTarget.getParentFile());
}
File fSource = new File(polishFilePath(source));
if (fSource.isDirectory()) {
exec("mklink /d " + target + " " + source, ".", true, true);
} else {
exec("mklink /h " + target + " " + source, ".", true, true);
}
}
开发者ID:DataAgg,项目名称:DAFramework,代码行数:20,代码来源:SysToolkit.java
示例3: 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
示例4: main
import jodd.io.FileUtil; //导入依赖的package包/类
public static void main(String[] args) {
EsRestSpecGen codeGen = new EsRestSpecGen();
String specHome = ".\\api\\";
codeGen.sourceDir = "..\\wES-client\\src\\main\\java\\";
codeGen.pkg = "org.datasays.wes";
Iterator<File> iterator = FindFileUtil.search(true, false, specHome);
while (iterator.hasNext()) {
File f = iterator.next();
if (f.getName().endsWith(".json")) {
try {
String jsoncode = FileUtil.readUTFString(f);
codeGen.parseCode(jsoncode);
codeGen.writeJavaFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
codeGen.writeEsHelper();
}
开发者ID:DataSays,项目名称:wES,代码行数:21,代码来源:EsRestSpecGen.java
示例5: 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
示例6: main
import jodd.io.FileUtil; //导入依赖的package包/类
public static void main(String[] args) {
EsRestSpecGen4Retrofit parser = new EsRestSpecGen4Retrofit();
String specHome = ".\\wES-toolkit\\api\\";
Iterator<File> iterator = FindFileUtil.search(true, false, specHome);
while (iterator.hasNext()) {
File f = iterator.next();
if (f.getName().endsWith(".json")) {
try {
String jsoncode = FileUtil.readUTFString(f);
parser.parseCode(jsoncode);
} catch (IOException e) {
e.printStackTrace();
}
}
}
parser.writeToFile(".\\wES-client\\src\\main\\java\\org\\datasays\\wes\\client\\EsService.java");
}
开发者ID:DataSays,项目名称:wES,代码行数:18,代码来源:EsRestSpecGen4Retrofit.java
示例7: convert
import jodd.io.FileUtil; //导入依赖的package包/类
public File convert(Object value) {
if (value instanceof FileUpload) {
FileUpload fileUpload = (FileUpload) value;
InputStream in = null;
try {
in = fileUpload.getFileInputStream();
File tempFile = FileUtil.createTempFile();
FileUtil.writeStream(tempFile, in);
return tempFile;
} catch (IOException ioex) {
return null;
} finally {
StreamUtil.close(in);
}
}
return null;
}
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:22,代码来源:FileUploadToFileTypeConverter.java
示例8: getFileBytes
import jodd.io.FileUtil; //导入依赖的package包/类
/**
* Returns cached file bytes.
*/
public byte[] getFileBytes(File file) throws IOException {
byte[] bytes = cache.get(file);
if (bytes != null) {
return bytes;
}
// add file
bytes = FileUtil.readBytes(file);
if ((maxFileSize != 0) && (file.length() > maxFileSize)) {
// don't cache files that size exceed max allowed file size
return bytes;
}
usedSize += bytes.length;
// put file into cache
// if used size > total, purge() will be invoked
cache.put(file, bytes);
return bytes;
}
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:26,代码来源:FileLFUCache.java
示例9: useWatchFile
import jodd.io.FileUtil; //导入依赖的package包/类
/**
* Enables usage of provided watch file.
*/
public DirWatcher useWatchFile(String name) {
watchFile = new File(dir, name);
if (!watchFile.isFile() || !watchFile.exists()) {
try {
FileUtil.touch(watchFile);
} catch (IOException ioex) {
throw new DirWatcherException("Invalid watch file: " + name, ioex);
}
}
watchFileLastAccessTime = watchFile.lastModified();
return this;
}
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:19,代码来源:DirWatcher.java
示例10: getPartnerNameFromTransparencyRegister
import jodd.io.FileUtil; //导入依赖的package包/类
private String getPartnerNameFromTransparencyRegister(String string) {
try {
File file = new File(SystemUtil.tempDir(), "partner.html");
NetUtil.downloadFile(
"http://ec.europa.eu/transparencyregister/public/consultation/displaylobbyist.do?id=" + string,
file);
name = "";
// create Jerry, i.e. document context
Jerry doc = Jerry.jerry(FileUtil.readString(file));
// parse
doc.$("div.panel-body h4").each(new JerryFunction() {
public boolean onNode(Jerry $this, int index) {
name = $this.$("b").text();
return true;
}
});
} catch (IOException e) {
e.printStackTrace();
}
log.info(name);
return name;
}
开发者ID:TransparencyInternationalEU,项目名称:lobbycal,代码行数:27,代码来源:MeetingService.java
示例11: delete
import jodd.io.FileUtil; //导入依赖的package包/类
@Override
public void delete(String repositoryName, Long id, String name) throws IOException {
/*
* 1. Repository exists.
* 2. Found a RepoXmlFile by id.
* 3. Name from database equals to name from parameter.
* All conditions are true, then delete xml file.
*/
RepoXml lRepoXml = getRepoXmlByNameOrThrow(repositoryName);
RepoXmlFile lRepoXmlFile = repoXmlFileDao.selectByIdDependsRepoXmlId(id, lRepoXml.getId());
Validate.notNull(lRepoXmlFile, "XML file not found: (id=" + id + ")" + name);
Validate.isTrue(name.equals(lRepoXmlFile.getFileName()),
"XML file name incorrect, desired: " + lRepoXmlFile.getFileName() + " give: " + name);
repoXmlFileDao.deleteById(lRepoXmlFile.getId());
try {
FileUtil.deleteFile(new File(ConfigurationUtil.getXmlRepositoryDir(repositoryName), lRepoXmlFile.getFileName()));
} catch (FileNotFoundException ignore) {
}
}
开发者ID:oing9179,项目名称:AndroidSDKLiteServer,代码行数:20,代码来源:XmlRepositoryEditorServiceImpl.java
示例12: delete
import jodd.io.FileUtil; //导入依赖的package包/类
@Override
public void delete(Long id, String name) throws IOException {
RepoXml lRepoXml = getById(id);
// 1. If repositoryName have no matches in database, reject.
Validate.isTrue(lRepoXml.getName().equals(name),
"Repository name doesn't match, desired: " + lRepoXml.getName() + ", give: " + name + ".");
// 2. Delete record from table xml_repo_file.
repoXmlFileDao.deleteDependsRepoXmlId(lRepoXml.getId());
// 3. Clear dependency for zip repository who depends on this.
repoZipDao.updateClearDependencyFromRepoXml(lRepoXml.getId());
// 4. Delete files from this repository.
File lFileDirTargetXmlRepo = ConfigurationUtil.getXmlRepositoryDir(lRepoXml.getName());
try {
FileUtil.deleteDir(lFileDirTargetXmlRepo);
} catch (FileNotFoundException ignore) {
}
// 5. Delete record of xml_repo.
repoXmlDao.deleteById(lRepoXml.getId());
}
开发者ID:oing9179,项目名称:AndroidSDKLiteServer,代码行数:20,代码来源:XmlRepositoryListServiceImpl.java
示例13: 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
示例14: createTest
import jodd.io.FileUtil; //导入依赖的package包/类
/**
* 创建测试邮件
* @param books
*/
public static String createTest(Map<String,String> books){
try {
Jerry doc = jerry(FileUtil.readString(Thread.currentThread().getContextClassLoader().getResource("/templateTest").getFile()));
for(Map.Entry<String,String> book:books.entrySet()){
doc.$("#booksContent").append(createNode(book));
}
return doc.htmlAll(true);
} catch (IOException e) {
e.printStackTrace();
System.out.println("未找到文件");
}
return null;
}
开发者ID:1994,项目名称:cdulibrary,代码行数:22,代码来源:TemplateFactory.java
示例15: write
import jodd.io.FileUtil; //导入依赖的package包/类
/**
* Writes file upload item to destination file.
*/
public File write(File destination) throws IOException {
if (data != null) {
FileUtil.writeBytes(destination, data);
} else if (tempFile != null) {
FileUtil.move(tempFile, destination);
}
return destination;
}
开发者ID:febit,项目名称:febit,代码行数:12,代码来源:UploadFile.java
示例16: getFileContent
import jodd.io.FileUtil; //导入依赖的package包/类
/**
* Returns the content of file upload item.
*/
public byte[] getFileContent() throws IOException {
if (data != null) {
return data;
}
if (tempFile != null) {
return FileUtil.readBytes(tempFile);
}
return null;
}
开发者ID:febit,项目名称:febit,代码行数:13,代码来源:UploadFile.java
示例17: 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
示例18: fromJson
import jodd.io.FileUtil; //导入依赖的package包/类
public static <T extends Object> T fromJson(File f, Class<T> cls) {
try {
return fromJson(FileUtil.readString(f, "utf-8"), cls);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
return null;
}
}
开发者ID:DataAgg,项目名称:DAFramework,代码行数:9,代码来源:WJsonUtils.java
示例19: 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
示例20: delFiles
import jodd.io.FileUtil; //导入依赖的package包/类
public static void delFiles(String file) throws Exception {
File f = new File(polishFilePath(file));
if (f.exists()) {
LOG.info("删除" + file);
if (f.isDirectory()) {
if (isSymbolicLink(file)) {
exec("rd /q " + f.getAbsolutePath() + "", ".", true, true);
} else {
FileUtil.deleteDir(f.getAbsolutePath(), new FileUtilParams().setRecursive(true).setContinueOnError(false));
}
} else {
FileUtil.delete(f.getAbsolutePath(), new FileUtilParams().setContinueOnError(false));
}
}
}
开发者ID:DataAgg,项目名称:DAFramework,代码行数:16,代码来源:SysToolkit.java
注:本文中的jodd.io.FileUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论