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


Java UploadedFile.getInputStream方法代码示例

本文整理汇总了Java中org.richfaces.model.UploadedFile.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java UploadedFile.getInputStream方法的具体用法?Java UploadedFile.getInputStream怎么用?Java UploadedFile.getInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.richfaces.model.UploadedFile的用法示例。


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

示例1: copyUploadedFile

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Copy uploaded file to byte array.
 * 
 * @param uploadedFile
 * @return byte array
 * @throws IOException 
 */
public static byte[] copyUploadedFile(UploadedFile uploadedFile) throws IOException {
    
    InputStream in = uploadedFile.getInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        int b;
        while ((b = in.read()) != -1) {
            out.write(b);
        }
    } finally {
        out.close();
        in.close();
    }
    return out.toByteArray();
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:23,代码来源:Utils.java

示例2: updateCert

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
private void updateCert(UploadedFile item) {
	InputStream is = null;
	OutputStream os = null;
	try {
		is = item.getInputStream();
		os = new FileOutputStream(getTempCertDir() + this.uploadMarker);
		BufferedOutputStream bos = new BufferedOutputStream(os);

		IOUtils.copy(is, bos);
		bos.flush();
	} catch (IOException ex) {
		log.error("Failed to upload certicicate", ex);
	} finally {
		IOUtils.closeQuietly(is);
		IOUtils.closeQuietly(os);
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:18,代码来源:ManageCertificateAction.java

示例3: updateTrsutStoreCert

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
private void updateTrsutStoreCert(UploadedFile item) {
	InputStream is = null;
	try {
		is = item.getInputStream();
		String certificate = IOUtils.toString(is);
		this.trustStoreCertificateUploadMarker.setCertificate(certificate);

		this.trustStoreCertificateUploadMarker.setAddedAt(new Date());
		this.trustStoreCertificateUploadMarker.setAddedBy(currentPerson.getDn());

	} catch (IOException ex) {
		log.error("Failed to upload key", ex);
	} finally {
		IOUtils.closeQuietly(is);
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:17,代码来源:ManageCertificateAction.java

示例4: updateKey

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
private void updateKey(UploadedFile item) {
	InputStream is = null;
	OutputStream os = null;
	try {
		is = item.getInputStream();
		os = new FileOutputStream(getTempCertDir() + this.uploadMarker.replace("crt", "key"));
		BufferedOutputStream bos = new BufferedOutputStream(os);

		IOUtils.copy(is, bos);
		bos.flush();
	} catch (IOException ex) {
		log.error("Failed to upload key", ex);
	} finally {
		IOUtils.closeQuietly(is);
		IOUtils.closeQuietly(os);
	}
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:18,代码来源:ManageCertificateAction.java

示例5: copyUploadedFile

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Copy uploaded file to byte array.
 *
 * @param uploadedFile
 * @return byte array
 * @throws IOException
 */
public byte[] copyUploadedFile(UploadedFile uploadedFile) throws IOException {

    InputStream in = uploadedFile.getInputStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        int b;
        while ((b = in.read()) != -1) {
            out.write(b);
        }
    } finally {
        out.close();
        in.close();
    }
    return out.toByteArray();
}
 
开发者ID:GluuFederation,项目名称:oxTrust,代码行数:23,代码来源:ServiceUtil.java

示例6: saveFile

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
public String saveFile( UploadedFile file ) throws IOException
{
	String name = file.getName().replace(" ", "_");
	
	//ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
	File result = new File( cm.getImportPath() + "//" + name );
	
	FileOutputStream output = new FileOutputStream(result);
	
	InputStream input = file.getInputStream();
	
	IOUtils.copy( input, output );
	
	input.close( );
	
	output.close( );
	
	return name;
}
 
开发者ID:Inspiredsoft,项目名称:parco,代码行数:20,代码来源:BaseFileUpload.java

示例7: listener

import org.richfaces.model.UploadedFile; //导入方法依赖的package包/类
public void listener(FileUploadEvent event) throws Exception {
    final UploadedFile uploadedFile = event.getUploadedFile();
    
    if (uploadedFile.getFileExtension().compareToIgnoreCase("zip")!=0 ) {
        error("Only files ended with '.zip' are accepted");
        return;
    }
    
    final Path folder = Paths.get(ConstantesAplicacao.DIR_BASE_JNLP);
    String filename = FilenameUtils.getBaseName(uploadedFile.getName()); 
    String extension = FilenameUtils.getExtension(uploadedFile.getName());
    Path tempPath = Files.createTempFile(folder, filename, "." + extension);
    
    try (InputStream input = uploadedFile.getInputStream()) {
        Files.copy(input, tempPath, StandardCopyOption.REPLACE_EXISTING);
    }
    
    if(FileUtils.extractZip(tempPath.toFile(), tempPath.toFile().getParentFile())){
        String currentVersion = uploadedFile.getName().substring(0, uploadedFile.getName().length()-4);
        StringBuilder sb = new StringBuilder();
        if(archiveInfo.existsFile()){
            // pegando as duas primeiras linhas do arquivo
            String infoUltimo = archiveInfo.readLine();
            sb.append("Último upload");
            sb.append(infoUltimo.substring(infoUltimo.indexOf(":")));
            sb.append("\n");
            infoUltimo = archiveInfo.readLine();
            sb.append("Última versão");
            sb.append(infoUltimo.substring(infoUltimo.indexOf(":")));
            sb.append("\n");
            archiveInfo.closeFileReader();
            archiveInfo.deleteFile();
        }else{
            sb.append("Último upload: Nunca\n");
            sb.append("Última versão: Nenhuma\n");
        }
        archiveInfo.openAppendAndClose("Upload atual em: "+new Date());
        archiveInfo.openAppendAndClose("Versão atual: "+currentVersion);
        archiveInfo.openAppendAndClose("-----------------------------------");
        archiveInfo.openAppendAndClose(sb.toString());
    }

    files.add(uploadedFile);
    uploadsAvailable--;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:46,代码来源:PeixeEspadaBean.java


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