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


Java IOUtils类代码示例

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


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

示例1: load

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
public void load() {
    mimeTypesMap = new HashMap<>();
    try {
        JsonNode jsonNode = MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream("/MIMETypes.json")));
        for (JsonNode node : jsonNode) {
            JsonNode type = node.path("name");
            JsonNode ext = node.path("extension");
            if (!type.isMissingNode()) {
                mimeTypesMap.put(type.asText(), ext.isMissingNode() ? "" : ext.asText());
            }
        }

        mimeTypesMap = Collections.unmodifiableMap(mimeTypesMap);
        LOG.debug("MIME types loaded: {}", mimeTypesMap);

        mimeTypes = new ArrayList<>(mimeTypesMap.keySet());
        Collections.sort(mimeTypes);
        mimeTypes = Collections.unmodifiableList(mimeTypes);
    } catch (Exception e) {
        LOG.error("Error reading file MIMETypes from resources", e);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:23,代码来源:MIMETypesLoader.java

示例2: getResource

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
@Override
public IResource getResource() {
	ConcatBundleResource bundleResource = new ConcatBundleResource(getProvidedResources()) {

		@Override
		protected byte[] readAllResources(List<IResourceStream> resources)
				throws IOException, ResourceStreamNotFoundException {
			ByteArrayOutputStream output = new ByteArrayOutputStream();
			for (IResourceStream curStream : resources) {
				IOUtils.copy(curStream.getInputStream(), output);
				output.write(";".getBytes());
			}

			byte[] bytes = output.toByteArray();

			if (getCompressor() != null) {
				String nonCompressed = new String(bytes, "UTF-8");
				bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
			}

			return bytes;
		}
		
	};
	ITextResourceCompressor compressor = getCompressor();
	if (compressor != null) {
		bundleResource.setCompressor(compressor);
	}
	return bundleResource;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:31,代码来源:JavaScriptConcatResourceBundleReference.java

示例3: RoomsPanel

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
public RoomsPanel(String id, List<Room> rooms) {
	super(id);
	this.rooms = rooms;
	clients = new ListView<Client>("clients", clientsInRoom){
		private static final long serialVersionUID = 1L;

		@Override
		protected void populateItem(final ListItem<Client> item) {
			Client client = item.getModelObject();
			final Long userId = client.getUserId();
			item.add(new Image("clientImage", new ByteArrayResource("image/jpeg") {
				private static final long serialVersionUID = 1L;

				@Override
				protected ResourceResponse newResourceResponse(Attributes attributes) {
					ResourceResponse rr = super.newResourceResponse(attributes);
					rr.disableCaching();
					return rr;
				}

				@Override
				protected byte[] getData(Attributes attributes) {
					String uri = null;
					if (userId != null) {
						uri = getBean(UserDao.class).get(userId > 0 ? userId : -userId).getPictureuri();
					}
					File img = OmFileHelper.getUserProfilePicture(userId, uri);
					try (InputStream is = new FileInputStream(img)) {
						return IOUtils.toByteArray(is);
					} catch (Exception e) {
						//no-op
					}
					return null;
				}
			}));
			item.add(new Label("clientLogin", client.getUser().getLogin()));
			item.add(new Label("from", client.getConnectedSince()));
		}
	};
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:41,代码来源:RoomsPanel.java

示例4: getImageData

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
@Override
protected byte[] getImageData(Attributes attributes) {
    InputStream inputStream = null;
    try {
        File file = new File(artifactoryHome.getLogoDir(), "logo");
        inputStream = file.inputStream();
        return IOUtils.toByteArray(inputStream);
    } catch (IOException e) {
        throw new RuntimeException("Can't read image file", e);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:14,代码来源:LogoResource.java

示例5: getImageData

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
@Override
protected byte[] getImageData(Attributes attributes) {
    InputStream inputStream = null;
    try {
        inputStream = file.inputStream();
        return IOUtils.toByteArray(inputStream);
    } catch (IOException e) {
        throw new RuntimeException("Can't read image file", e);
    } finally {
        IOUtils.closeQuietly(inputStream);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:13,代码来源:ImageFileResource.java

示例6: loadSecurityProperties

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
private Properties loadSecurityProperties() {
    Properties prop = new Properties();
    String file = DEV_FILE_PATH;
    boolean devMode = new File(file).exists();
    InputStream in = null;
    try {
        if (devMode) {
            in = new FileInputStream(file);
        } else {
            if (cachedProperties != null) {
                return cachedProperties;
            }
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null) {
                cl = getClass().getClassLoader();
            }
            in = cl.getResourceAsStream(PROD_FILE_PATH);
        }
        prop.load(in);
        if (!devMode) {
            cachedProperties = prop;
        }
        return prop;
    } catch (IOException e) {
        throw new IllegalStateException("Error reading from file " +file+": "+e.getMessage());
    } finally {
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:30,代码来源:SpringSecurityAuthorizationStrategy.java

示例7: getCompiledStylesheet

import org.apache.wicket.util.io.IOUtils; //导入依赖的package包/类
@Override
// If checkCacheInvalidation is true and, before invocation, a cached value exists and is not up to date, we evict the cache entry. 
@CacheEvict(value = "scssService.compiledStylesheets", 
		key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)",
		beforeInvocation = true,
		condition= "#checkCacheEntryUpToDate && !(caches.?[name=='scssService.compiledStylesheets'][0]?.get(T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path))?.get()?.isUpToDate() ?: false)"
		)
// THEN, we check if a cached value exists. If it does, it is returned ; if not, the method is called. 
@Cacheable(value = "scssService.compiledStylesheets",
		key = "T(fr.openwide.core.wicket.more.css.scss.service.ScssServiceImpl).getCacheKey(#scope, #path)")
public ScssStylesheetInformation getCompiledStylesheet(Class<?> scope, String path, boolean checkCacheEntryUpToDate)
		throws ServiceException {
	String scssPath = getFullPath(scope, path);
	
	try {
		JSassScopeAwareImporter importer = new JSassScopeAwareImporter(SCOPES);
		importer.addSourceUri(scssPath);
		
		Compiler compiler = new Compiler();
		Options options = new Options();
		options.setOutputStyle(OutputStyle.EXPANDED);
		options.setIndent("\t");
		options.getImporters().add(importer);
		
		ClassPathResource scssCpr = new ClassPathResource(scssPath);
		
		Context fileContext = new StringContext(IOUtils.toString(scssCpr.getInputStream()), new URI("classpath", "/" + scssPath, null), null, options);
		Output output = compiler.compile(fileContext);
		// Write result
		ScssStylesheetInformation compiledStylesheet = new ScssStylesheetInformation(scssPath, output.getCss());
		
		for (String sourceUri : importer.getSourceUris()) {
			ClassPathResource cpr = new ClassPathResource(sourceUri);
			compiledStylesheet.addImportedStylesheet(new ScssStylesheetInformation(sourceUri, cpr.lastModified()));
		}
		
		return compiledStylesheet;
	} catch (RuntimeException | IOException | URISyntaxException | CompilationException e) {
		throw new ServiceException(String.format("Error compiling %1$s", scssPath), e);
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:42,代码来源:ScssServiceImpl.java


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