📄 gdfile.java
字号:
/*
* gdFile.java
* Generated using xgen and texen from bean.vm
* Sun Mar 14 17:34:12 CST 2004
*/
package com.sure.oa.gdfile;
import org.apache.xerces.utils.Base64;
import java.io.*;
import com.sure.oa.attachment.*;
/**
* @author datonghuiren@sohu.com
*/
public class gdFile extends gdFileBase {
public String getFilePath(){
return path+site+"/"+fileName;
}
public String getTitleWithOutPre(){
String oldTitle=getTitle();
return oldTitle.substring(0,oldTitle.lastIndexOf("."));
}
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(getTitleWithOutPre()).append("\"");
}
retValue.append(" 文件标题=\"").append(getTitle()).append("\"");
retValue.append(" 编码方式=\"").append("BASE64").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("\"").append(">");
retValue.append(new String(Base64.encode(getContent())));
retValue.append("</"+title+">");
return retValue;
}
public byte[] getContent() throws FileNotFoundException,IOException{
String path=attachmentManager.getUploadPath();
File file=new File(path+getFilePath());
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
int size = (int)file.length();
byte[] content = new byte[size];
int data, i = 0;
try{
while( (data = bis.read()) != -1 ){
content[i++] = (byte)data;
}
bis.close();
}
catch(Exception e){
e.printStackTrace();
}
finally{
return content;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -