如何在JSF中保存上传的文件
<t:inputFileUpload>
<p:fileUpload>
<h:inputFile>
.
private UploadedFile uploadedFile; // +getter+setterpublic String save() throws IOException { String name = uploadedFile.getName(); System.out.println("File name: " + name); String type = uploadedFile.getContentType(); System.out.println("File type: " + type); long size = uploadedFile.getSize(); System.out.println("File size: " + size); InputStream stream = uploadedFile.getInputStream(); byte[] buffer = new byte[(int) size]; stream.read(buffer, 0, (int) size); stream.close(); }
HUX布斯
相关分类