类com.vaadin.server.FileResource源码实例Demo

下面列出了怎么用com.vaadin.server.FileResource的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: RDFUnit   文件: TestGenerationView.java
@Override
public void sourceGenerationExecuted(final Source source, final TestGenerationType generationType, final long testsCreated) {
    UI.getCurrent().access(() -> {
        Item item = resultsTable.getItem(source);
        if (testsCreated == 0 || item == null)
            return;

        String column = (generationType.equals(TestGenerationType.AutoGenerated) ? "Automatic" : "Manual");
        Property<Link> statusProperty = item.getItemProperty(column);
        String fileName;
        if (generationType.equals(TestGenerationType.AutoGenerated)) {
            fileName = CacheUtils.getSourceAutoTestFile(RDFUnitDemoSession.getBaseDir() + "tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new FileResource(new File(fileName))));
        } else {
            fileName = CacheUtils.getSourceManualTestFile("/org/aksw/rdfunit/tests/", source);
            statusProperty.setValue(new Link("" + testsCreated, new ClassResource(fileName)));
        }
        CommonAccessUtils.pushToClient();
    });

}
 
源代码2 项目: dubbox   文件: HomePageUI.java
private FileResource getFileResource(String path,String type){
    InputStream inputStream = null;
    try {
        ClassPathResource resource = new ClassPathResource(path);
        inputStream = resource.getInputStream();
        File tempFile = File.createTempFile("ds_" + System.currentTimeMillis(), type);
        FileUtils.copyInputStreamToFile(inputStream, tempFile);
        return new FileResource(tempFile);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
源代码3 项目: dubbo-switch   文件: HomePageUI.java
private FileResource getFileResource(String path,String type){
    InputStream inputStream = null;
    try {
        ClassPathResource resource = new ClassPathResource(path);
        inputStream = resource.getInputStream();
        File tempFile = File.createTempFile("ds_" + System.currentTimeMillis(), type);
        FileUtils.copyInputStreamToFile(inputStream, tempFile);
        return new FileResource(tempFile);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
源代码4 项目: cuba   文件: FileIconProvider.java
@Override
public Resource getIconResource(String iconPath) {
    Preconditions.checkNotEmptyString(iconPath, "Icon path should not be empty");

    String icon = iconPath.substring(FILE_PREFIX.length());
    File iconFile = new File(icon);
    if (!iconFile.exists()) {
        throw new IllegalArgumentException("Icon file does not exist: " + icon);
    }

    return new FileResource(iconFile);
}
 
源代码5 项目: chipster   文件: Icon.java
public static Resource getResource(String path) {
	return new FileResource(new File(path));
}