當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。