📄 dataheader.java
字号:
//Source file: D:/MyWork/com/jspupload/DataHeader.java
/////////////////////////////////////////////////////////////////////
// Author : Sean B.C. Ryu (幅豪冕)
// E-Mail : stater@chollian.net
// Date : 2000.9.10
// Update : 2000.9.20
// Version : 0.8
// Title : JSP File Uploader
// Class : DataHeader
// Update History :
// MIME鸥涝阑 掘阑 锭, 霉 巩磊啊 狐瘤绰 滚弊 荐沥(2000.9.20)
//
// 捞 颇老篮 JSP File Uploader狼 老何 涝聪促.
// 夯 橇肺弊伐 傈眉俊 措茄 历累鼻篮 幅豪冕俊霸 乐嚼聪促.
// 捞 橇肺弊伐 肚绰 家胶狼 荤侩捞唱 硅器绰 磊蜡酚嚼聪促.
// 窍瘤父 公窜栏肺 函版窍角 荐 绰 绝嚼聪促.
// 窜 捞 橇肺弊伐阑 捞侩窍咯 傍何窍脚 饶, 犁累己窍绰 巴俊 措秦辑绰
// 包咯窍瘤 臼摆嚼聪促.
// 榴芭款 Java 傍何啊 登辨 瑚聪促.
////////////////////////////////////////////////////////////////////
package com.jspupload;
public class DataHeader
{
private boolean file = false;
private String fieldName = null;
private String fullPathName = null;
private String fileName = null;
private String fileExtension = null;
private String contentType = null;
private String contentDisposition = null;
private String mimeType = null;
private String mimeSubType = null;
public DataHeader()
{
}
/**
@roseuid 39C1BF690069
*/
public DataHeader(String headerString)
{
this.file = headerString.indexOf("filename") > 0;
//Form Field狼 捞抚阑 掘绢柯促.
int startPosition = headerString.indexOf("name=\"") + "name=\"".length();
int endPosition = headerString.indexOf("\"", startPosition);
if( (startPosition > 0) && (endPosition > 0) )
{
this.fieldName = headerString.substring(startPosition, endPosition);
}
if( isFile() )
{
// Upload瞪 颇老狼 Full Path 疙阑 掘绢柯促.
startPosition = headerString.indexOf("filename=\"") + "filename=\"".length();
endPosition = headerString.indexOf("\"", startPosition);
if( (startPosition > 0) && (endPosition > 0) )
{
this.fullPathName = headerString.substring(startPosition, endPosition);
}
// Content 鸥涝阑 掘绢柯促.
startPosition = headerString.indexOf("Content-Type: ") + "Content-Type: ".length();
if( startPosition > 0 )
{
this.contentType = headerString.substring(startPosition);
}
// Content disposition阑 掘绢柯促.
startPosition = headerString.indexOf("Content-Disposition: ") + "Content-Disposition: ".length();
endPosition = headerString.indexOf(";", startPosition);
this.contentDisposition = headerString.substring(startPosition, endPosition);
// file 疙阑 掘绢柯促.
if((startPosition = this.fullPathName.lastIndexOf(47)) > 0)
{
this.fileName = this.fullPathName.substring(startPosition + 1);
}
else if((startPosition = this.fullPathName.lastIndexOf(92)) > 0)
{
this.fileName = this.fullPathName.substring(startPosition + 1);
}
else
{
this.fileName = this.fullPathName;
}
// file狼 犬厘磊甫 掘绰促.
if((startPosition = this.fileName.lastIndexOf(46)) > 0 )
{
this.fileExtension = this.fileName.substring(startPosition+1);
}
else
{
this.fileExtension = "";
}
// MIME 鸥涝苞 MIME 辑宏 鸥涝阑 掘绰促.
if((startPosition = this.contentType.indexOf("/")) > 0)
{
this.mimeType = this.contentType.substring(0,startPosition);
this.mimeSubType = this.contentType.substring(startPosition+1);
}
else
{
this.mimeType = this.contentType;
this.mimeSubType = this.contentType;
}
}
}
/**
@roseuid 39C1BF8E0370
*/
public boolean isFile()
{
return this.file;
}
/**
@roseuid 39C1BF9C0185
*/
public String getFieldName()
{
return this.fieldName;
}
/**
@roseuid 39C1BFAB02C7
*/
public String getFullPathName()
{
return this.fullPathName;
}
/**
@roseuid 39C1BFDB033E
*/
public String getFileName()
{
return this.fileName;
}
/**
@roseuid 39C1BFE703BE
*/
public String getFileExtension()
{
return this.fileExtension;
}
/**
@roseuid 39C1BFFB02AE
*/
public String getContentType()
{
return this.contentType;
}
/**
@roseuid 39C1C00E02C0
*/
public String getContentDisposition()
{
return this.contentDisposition;
}
/**
@roseuid 39C1C0280263
*/
public String getMimeType()
{
return this.mimeType;
}
/**
@roseuid 39C1C0350121
*/
public String getMimeSubType()
{
return this.mimeSubType;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -