001
014
015 package com.liferay.portal.json.data;
016
017 import com.liferay.portal.kernel.util.Base64;
018 import com.liferay.portal.kernel.util.FileUtil;
019
020 import java.io.File;
021 import java.io.IOException;
022
023
026 public class FileData {
027
028 public FileData(File file) {
029 byte[] bytes = null;
030
031 try {
032 bytes = FileUtil.getBytes(file);
033 }
034 catch (IOException ioe) {
035 bytes = null;
036 }
037
038 _content = Base64.encode(bytes);
039
040 _name = file.getName();
041 _size = file.length();
042 }
043
044 public String getContent() {
045 return _content;
046 }
047
048 public String getName() {
049 return _name;
050 }
051
052 public long getSize() {
053 return _size;
054 }
055
056 public void setContent(String content) {
057 _content = content;
058 }
059
060 public void setName(String name) {
061 _name = name;
062 }
063
064 public void setSize(long size) {
065 _size = size;
066 }
067
068 private String _content;
069 private String _name;
070 private long _size;
071
072 }