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


Java UploadedFile.getInputstream方法代码示例

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


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

示例1: UploadedFileIterator

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public UploadedFileIterator(UploadedFile item, String... extension) throws IOException {
    super();
    this.extension = extension;
    isZip = item.getFileName().toLowerCase().endsWith(".zip");
    itemInputStream = item.getInputstream();
    if (isZip) {
        try {
            in = new MyInputStream(
                    new ArchiveStreamFactory().createArchiveInputStream("zip", itemInputStream));
            // moveNext();
        } catch (ArchiveException e) {
            throw new IOException(e);
        }
    } else if (isValid(item.getFileName())) {
        next = new FileInputStreamWrapper(item.getFileName(), itemInputStream);
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:18,代码来源:UploadedFileIterator.java

示例2: restore

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public boolean restore(UploadedFile file) {
  List<String> command = new ArrayList<String>();
  command.add("mysql");
  command.add("-u" + USERNAME);
  command.add("-p" + PASSWORD);
  command.add(DATABASE);
  try {
    InputStream inputStream = file.getInputstream();
    Process process = new ProcessBuilder(command).start();
    byte[] bytes = new byte[1024];
    int read;
    while ((read = inputStream.read(bytes)) != -1) {
      process.getOutputStream().write(bytes, 0, read);
    }
    inputStream.close();
    process.getOutputStream().flush();
    process.getOutputStream().close();
    process.waitFor();
    if (process.exitValue() == 0) {
      return true;
    }
    return false;
  } catch (Exception ex) {
    logger.log(Level.SEVERE, null, ex);
    return false;
  }
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:28,代码来源:MySQLAccess.java

示例3: uploadFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void uploadFile( FileUploadEvent event ) {
	try {
		UploadedFile file = event.getFile();
		InputStream is = file.getInputstream();
		OutputStream os = new FileOutputStream(new File(getTmpDir(), file.getFileName()));
		IOUtils.copy(is, os);
		is.close();
		os.close();
		files.add(file.getFileName());
		if( isUsingMsf() )
			getCfg().setPsmScore(ScoreType.SEQUEST_XCORR);
	} catch( Exception e ) {			
	}
}
 
开发者ID:akrogp,项目名称:EhuBio,代码行数:15,代码来源:ExperimentMB.java

示例4: uploadFasta

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void uploadFasta( FileUploadEvent event ) {
	try {
		UploadedFile file = event.getFile();
		InputStream is = file.getInputstream();
		OutputStream os = new FileOutputStream(new File(getFastaDir(), file.getFileName()));
		IOUtils.copy(is, os);
		is.close();
		os.close();
	} catch( Exception e ) {			
	}
}
 
开发者ID:akrogp,项目名称:EhuBio,代码行数:12,代码来源:DatabaseMB.java

示例5: parse

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Parse XML from file with classes in classpath
 *
 * @param file
 * @param classpath
 * @return JAXB root element
 */
@SuppressWarnings("rawtypes")
public JAXBElement parse(UploadedFile file, String classpath)
{
    JAXBContext jc;
    try
    {
        /**
         * Read XML(JAXB) annotations from the classes in this package *
         */
        jc = JAXBContext.newInstance(classpath);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        BufferedInputStream bis = new BufferedInputStream(file.getInputstream());
        return (JAXBElement) unmarshaller.unmarshal(bis);
    }
    catch (JAXBException | OutOfMemoryError | IOException e)
    {
        System.err.println("Parsing of " + file.getFileName() + " failed");
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:tijs14tijs,项目名称:ROAD,代码行数:29,代码来源:GenericParser.java

示例6: analyzeAndCopyXmlFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
private UploadedFileInformation analyzeAndCopyXmlFile( UploadedFile file ) throws IOException {
	// xml file
	UploadedFileInformation fileInformation = new UploadedFileInformation();
	/*
	 * CG / 2012-01-06: don't use only file.getFileName() - which uses FileItem.getName() -
	 * because IE will return the whole path but not just the file name,
	 * see http://commons.apache.org/fileupload/faq.html#whole-path-from-IE
	 */
	String fileName = FilenameUtils.getName( file.getFileName() );
	fileInformation.setFileName( fileName );
	fileInformation.setFileType( file.getContentType() );
	fileInformation.setFileSize( file.getSize() );
	InputStream in = file.getInputstream();
	DatasetDAO dataSetDao = new DatasetDAO();

	ILCDTypes type = dataSetDao.determineDatasetType( in );
	in.close();
	fileInformation.setIlcdType( type );
	if ( type == null ) {
		ImportHandler.logger.error( "Cannot determine file type" );
		return fileInformation;
	}

	String targetDirectory = this.getDataSetDirectory( type );
	if ( targetDirectory == null ) {
		fileInformation.setMessage( "Warning: The XML file does not contain an ILCD data set; file ignored" );
		return fileInformation;
	}
	in = file.getInputstream();
	this.copyFile( in, targetDirectory, fileName );
	in.close();
	fileInformation.setPathName( targetDirectory + "/" + fileName );

	return fileInformation;
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:36,代码来源:ImportHandler.java

示例7: analyzeAndCopyArchive

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
private UploadedFileInformation analyzeAndCopyArchive( UploadedFile file ) throws IOException {
	UploadedFileInformation fileInformation = new UploadedFileInformation();
	/*
	 * CG / 2012-01-06: don't use only file.getFileName() - which uses FileItem.getName() -
	 * because IE will return the whole path but not just the file name,
	 * see http://commons.apache.org/fileupload/faq.html#whole-path-from-IE
	 */
	String fileName = FilenameUtils.getName( file.getFileName() );
	fileInformation.setFileName( fileName );
	fileInformation.setFileType( file.getContentType() );
	fileInformation.setFileSize( file.getSize() );

	String targetDirectory = this.getUploadDirectory();
	InputStream in = file.getInputstream();
	this.copyFile( file.getInputstream(), targetDirectory, fileName );
	in.close();
	fileInformation.setPathName( targetDirectory + "/" + fileName );

	return fileInformation;
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:21,代码来源:ImportHandler.java

示例8: analyzeAndCopyOtherFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
private UploadedFileInformation analyzeAndCopyOtherFile( UploadedFile file ) throws IOException {
	UploadedFileInformation fileInformation = new UploadedFileInformation();
	/*
	 * CG / 2012-01-06: don't use only file.getFileName() - which uses FileItem.getName() -
	 * because IE will return the whole path but not just the file name,
	 * see http://commons.apache.org/fileupload/faq.html#whole-path-from-IE
	 */
	String fileName = FilenameUtils.getName( file.getFileName() );
	fileInformation.setFileName( fileName );
	fileInformation.setFileType( file.getContentType() );
	fileInformation.setFileSize( file.getSize() );

	String targetDirectory = this.getUploadDirectory() + "/" + "external_docs";
	InputStream in = file.getInputstream();
	this.copyFile( file.getInputstream(), targetDirectory, fileName );
	in.close();
	fileInformation.setPathName( targetDirectory + "/" + fileName );

	return fileInformation;
}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:21,代码来源:ImportHandler.java

示例9: cadastrarGif

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void cadastrarGif() {
	
	if(validarDados()){
		NetgifxCommand command = new NetgifxCommand();
		UploadedFile arq = arquivo;
		try {
			
			FacesContext.getCurrentInstance().getResourceLibraryContracts();
			
			InputStream in = new BufferedInputStream(arq.getInputstream());
			
			String realPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/resources/static/img");
			
			File file = new File(realPath, arq.getFileName());
			
			gif.setCaminho("static/img/" + file.getName().replace(".gif", ""));
			gif.setDataPublicacao(LocalDate.now());
			
			
			ArquivoUtil.gravarArquivo(in, file);
			ConversorImagensUtil.converterGifParaPng(file);
			command.cadastrarGif(gif);
			
			
			gif = new Gif();
			arquivo = null;
			categoriasSelecionadas = null;
			
			FacesContext.getCurrentInstance().addMessage(
	                 null, new FacesMessage(FacesMessage.SEVERITY_INFO,
	                 "GIF cadastrado com sucesso!", "GIF cadastrado com sucesso!"));
			
		} catch (Exception ex) {
			FacesContext.getCurrentInstance().addMessage(
	                 null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
	                 "Ocorreu um erro ao tentar cadastrar o gif!", "Ocorreu um erro ao tentar cadastrar o gif!"));
		}
	}
}
 
开发者ID:pedrohnog,项目名称:Trabalhos-FIAP,代码行数:40,代码来源:CadastroGifMB.java

示例10: upload

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public String upload(UploadedFile file,String path) throws IOException{
   	try (InputStream input = file.getInputstream()) {
           Date date = new Date();
           long datetime = date.getTime();
           Files.copy(input, new File(path + file.getFileName()).toPath());
           File fileper = new File(path + file.getFileName());
   	    fileper.setReadable(true, false);
   	    fileper.setWritable(true, false);
   	    //setSshkeypath("/Users/darrenw/dicegui/DICEFITGUI/Uploads/"+ datetime + file.getFileName());
    	 String SSHKeyPath = path + datetime + file.getFileName();

   	   return SSHKeyPath;
   	}     
}
 
开发者ID:dice-project,项目名称:DICE-Fault-Injection-GUI,代码行数:15,代码来源:Uploader.java

示例11: copyFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
/**
     * Copy the file
     * @param file the file to copy
     * @return the result message
     */
    public FacesMessage copyFile(UploadedFile file) {
        try {
            deletePhoto();
            
            InputStream in = file.getInputstream();
            
            File tempFile = inputStreamToFile(in, Constants.TEMP_FILE);
            in.close();

            FacesMessage resultMsg;

            String user_name = (String) FacesContext.getCurrentInstance()
                    .getExternalContext().getSessionMap().get("username");

            User user = userFacade.findByUsername(user_name);
            //Group1 group = groupFacade
            // Need to implement when groups are a thing
            // Insert photo record into database
//            String extension = file.getContentType();
//            extension = extension.startsWith("image/") ? extension.subSequence(6, extension.length()).toString() : "png";
            List<File1> fileList = fileFacade.findFilesByUserID(user.getId());
            if (!fileList.isEmpty()) {
                fileFacade.remove(fileList.get(0));
            }

            fileFacade.create(new File1("png", user));
            File1 photo = fileFacade.findFilesByUserID(user.getId()).get(0);
            in = file.getInputstream();
            File uploadedFile = inputStreamToFile(in, photo.getFilename());
            BufferedImage icon = ImageIO.read(uploadedFile);
            BufferedImage rounded = makeRoundedCorner(icon);
            File circle = new File(uploadedFile.getName().substring(0, uploadedFile.getName().lastIndexOf('.')) + ".png");
            ImageIO.write(rounded, "png", circle);
            photo.setExtension("png");
            saveThumbnail(circle, photo);
            resultMsg = new FacesMessage("Success!", "File Successfully Uploaded!");
            return resultMsg;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new FacesMessage("Upload failure!",
            "There was a problem reading the image file. Please try again with a new photo file.");
    }
 
开发者ID:McBrosa,项目名称:MapChat,代码行数:49,代码来源:FileManager.java

示例12: copyFileGroup

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
/**
 * Take a file and store it in the group directory
 * @param file 
 * @param grp
 * @return the error/success message
 */
public FacesMessage copyFileGroup(UploadedFile file, Groups grp) {
    try {
        
        InputStream in = file.getInputstream();
        
        // create new directory if it doesnt exist
        new File(Constants.ROOT_DIRECTORY + "/" + grp.getId()).mkdirs();
        
        // create the file
        File tempFile = inputStreamToFile(in, grp.getId() + "/" + file.getFileName());
        in.close();

        FacesMessage resultMsg;

        // get the current username
        String user_name = (String) FacesContext.getCurrentInstance()
                .getExternalContext().getSessionMap().get("username");

        User user = userFacade.findByUsername(user_name);
        String extension = file.getContentType();

        // upload the file to the database
        fileFacade.create(new File1(extension, user, grp));
        
        resultMsg = new FacesMessage("Success!", "File Successfully Uploaded!");
        return resultMsg;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new FacesMessage("Upload failure!",
        "There was a problem reading the image file. Please try again with a new photo file.");
}
 
开发者ID:McBrosa,项目名称:MapChat,代码行数:39,代码来源:FileManager.java

示例13: storeFile

import org.primefaces.model.UploadedFile; //导入方法依赖的package包/类
public void storeFile(FileUploadEvent event) throws IOException {

        UploadedFile uploadedFile = event.getFile();
        String fileName = uploadedFile.getFileName().toLowerCase();

        try (InputStream inputStream = uploadedFile.getInputstream()) {

            Path targetPath = Files.createFile(tempFolderPath.resolve(fileName));

            FileUtil.storeFile(fileName, inputStream, targetPath);
        }
    }
 
开发者ID:drifted-in,项目名称:genopro-tools,代码行数:13,代码来源:FileUploadController.java


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