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


Java Files类代码示例

本文整理汇总了Java中play.libs.Files的典型用法代码示例。如果您正苦于以下问题:Java Files类的具体用法?Java Files怎么用?Java Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: rebuildAllIndexes

import play.libs.Files; //导入依赖的package包/类
public void rebuildAllIndexes() throws Exception {
    stop();
    File fl = new File(DATA_PATH);
    Files.deleteDirectory(fl);
    fl.mkdirs();
    List<ApplicationClass> classes = Play.classes.getAnnotatedClasses(Indexed.class);
    for (ApplicationClass applicationClass : classes) {
        List<JPABase> objects = JPA.em().createQuery(
                                        "select e from " + applicationClass.javaClass.getCanonicalName() + " as e")
                                        .getResultList();
        for (JPABase jpaBase : objects) {
            index(jpaBase, applicationClass.javaClass.getName());
        }
    }
    Logger.info("Rebuild index finished");
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:17,代码来源:FilesystemStore.java

示例2: delete

import play.libs.Files; //导入依赖的package包/类
public void delete(String name) {
    synchronized (this) {
        try {
            if (indexSearchers.containsKey(name)) {
                IndexReader rd = indexSearchers.get(name).getIndexReader();
                indexSearchers.get(name).close();
                indexSearchers.remove(name);
            }
            if (indexWriters.containsKey(name)) {
                indexWriters.get(name).close();
                indexWriters.remove(name);
            }
            File target = new File(DATA_PATH, name);
            if (target.exists() && target.isDirectory())
                Files.deleteDirectory(target);
        } catch (Exception e) {
            throw new UnexpectedException("Can't reopen reader", e);
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:FilesystemStore.java

示例3: testFileUpload

import play.libs.Files; //导入依赖的package包/类
@Test
public void testFileUpload() {
    Application app = fakeApplication();
    running(app, () -> {
        try {

            Files.TemporaryFileCreator temporaryFileCreator = app.injector().instanceOf(Files.TemporaryFileCreator.class);
            Materializer materializer = app.injector().instanceOf(Materializer.class);

            Path tempfilePath = createTempFile(null, "tempfile");
            write(tempfilePath, "My string to save".getBytes("utf-8"));

            Source<ByteString, CompletionStage<IOResult>> source = FileIO.fromPath(tempfilePath);
            Http.MultipartFormData.FilePart<Source<ByteString, ?>> part = new Http.MultipartFormData.FilePart<>("name", "filename", "text/plain", source);
            Http.RequestBuilder request = fakeRequest()
                    .method(POST)
                    .bodyMultipart(singletonList(part), temporaryFileCreator, materializer)
                    .uri("/upload");

            Result result = route(app, request);
            String actual = contentAsString(result);
            assertEquals("file size = 17", actual);
        } catch (IOException e) {
            fail(e.getMessage());
        }
    });
}
 
开发者ID:play2-maven-plugin,项目名称:play2-maven-test-projects,代码行数:28,代码来源:HomeControllerTest.java

示例4: asFile

import play.libs.Files; //导入依赖的package包/类
public File asFile(File file) {
    try {
        Files.copy(defaultFile, file);
        return file;
    } catch (Exception ex) {
        throw new UnexpectedException(ex);
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:9,代码来源:FileUpload.java

示例5: download

import play.libs.Files; //导入依赖的package包/类
public static void download(@As(binder=DomainModelBinder.class) List<DomainModel> pk, Format format) throws InterruptedException, IOException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchFieldException {
	{
		Study study = pk.get(0) instanceof Study ? (Study) pk.get(0) : ((Series) pk.get(0)).study;
		PersistentLogger.log("downloaded %s %s %s", pk.get(0) instanceof Study ? "study" : "series", pk, study.patient.pat_id);
	}
	File tmpDir = new File(Properties.getDownloads(), UUID.randomUUID().toString());
	tmpDir.mkdir();
	File outDir = await(new Downloader(format == null ? Format.dcm : format, tmpDir, Boolean.TRUE.equals(getUser().preferMultiframe), getUser().niftiMultiframeScript, Item.serialize(pk)).now());
	if (FileUtils.listFiles(outDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).isEmpty()) {
		error("Failed to retrieve files");
	}
	File zip = new File(tmpDir, String.format("%s.zip", outDir.getName()));
	Files.zip(outDir, zip);
	renderBinary(zip);
}
 
开发者ID:mwoodbri,项目名称:MRIdb,代码行数:16,代码来源:Application.java

示例6: doJob

import play.libs.Files; //导入依赖的package包/类
@Override
public void doJob() {
	for (String folderName : watchedFolders) {
		File folder = new File(Play.tmpDir, folderName);
		if (folder.exists()) {
			for (File file : folder.listFiles()) {
				if (TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - file.lastModified()) > 1) {
					Files.delete(file);
				}
			}
		}
	}
}
 
开发者ID:mwoodbri,项目名称:MRIdb,代码行数:14,代码来源:TmpWatch.java

示例7: save

import play.libs.Files; //导入依赖的package包/类
void save() {
    if (f != null) {
        File to = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
        Files.copy(f, to);
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:7,代码来源:FileAttachment.java


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