📄 attachment.java
字号:
/*
* attachment.java
* Generated using xgen and texen from bean.vm
* Wed Mar 03 13:44:52 CST 2004
*/
package com.sure.oa.attachment;
import org.apache.xerces.utils.Base64;
import java.io.*;
/**
* 将正文或附件存入数据库
* @author datonghuiren@sohu.com
*/
public class attachment extends attachmentBase {
/**
* @ return 获得文件在服务器上保存的完整路径
*/
public String getFilePath(){
return path+site+"/"+fileName;
}
public StringBuffer toXML(String type) throws FileNotFoundException,IOException{
String title="正文";
if(type.equals("1")) title="附件";
StringBuffer retValue = new StringBuffer();
retValue.append("<"+title+" 文件名=\"").append(getFileName()).append("\"");
if(type.equals("1")){
retValue.append(" 附件名称=\"").append(getTitle().substring(0,getTitle().lastIndexOf("."))).append("\"");
}
retValue.append(" 编码方式=\"").append("BASE64").append("\"");
retValue.append(" title=\"").append(getTitle()).append("\"");
retValue.append(" path=\"").append(getPath()).append("\"");
retValue.append(" site=\"").append(getSite()).append("\"");
retValue.append(" docId=\"").append(getDocId()).append("\"");
retValue.append(" fileSize=\"").append(getFileSize()).append("\"");
retValue.append(" 数据类型=\"").append(getMimeType()).append("\"");
retValue.append(">");
retValue.append(new String(Base64.encode(getContent())));
retValue.append("</"+title+">");
return retValue;
}
public byte[] getContent() throws FileNotFoundException,IOException{
String path=attachmentManager.getUploadPath();
FileInputStream inp = new FileInputStream(new File(path+getFilePath()));
byte[] buf = new byte[1024];
byte[] content=new byte[1024];
int length;
while((length=inp.read(buf))!=-1){
if(content != null && content.length > 0){
byte[] newbuf = new byte[content.length + length];
System.arraycopy(content, 0, newbuf, 0, content.length);
System.arraycopy(buf, 0, newbuf, content.length, length);
content = newbuf;
}
else
System.arraycopy(buf, 0, content, 0, length);
}
return content;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -