javax.servlet.ServletOutputStream output = response.getOutputStream();
File urlfile = new File(yourFile);
java.io.FileInputStream bis = new FileInputStream(yourFile);
BufferedOutputStream bos = new BufferedOutputStream(output);
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff, 0, bytesRead);
}
bos.close();
bis.close();
File urlfile = new File(yourFile);
java.io.FileInputStream bis = new FileInputStream(yourFile);
BufferedOutputStream bos = new BufferedOutputStream(output);
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff, 0, bytesRead);
}
bos.close();
bis.close();
public String[] stringSplit(String sourceString, String spliter)
{
String S1 = sourceString;
String S2 = spliter;
if(S1 == null || S2 == null || S1.equals("") || S2.equals(""))
{
return null;
}
else if(S1.length() <= S2.length())
{
if(S1.equals(S2))
{
return null;
}
else
{
String[] newArray = new String[1];
newArray[0] = S1;
return newArray;
}
}
else
{
String temp_String1 = "";
String temp_String2 = "";
Vector array = new Vector();
int length = S2.length();
int max = 0;
for(int i=0; i<S1.length(); i++)
{
max = (i + length >= S1.length()? S1.length():i + length);
temp_String1 = S1.substring(i, max);
if(temp_String1.equals(S2))
{
if(!temp_String2.equals(""))
{
array.addElement(temp_String2);
temp_String2 = "";
}
i += length - 1;
}
else
{
if(max!=S1.length())
{
temp_String2 += temp_String1.substring(0,1);
}
else
{
temp_String2 += temp_String1;
array.addElement(temp_String2);
i += length;
temp_String2="";
}
}
}
String[] returnArray = new String[array.size()];
array.copyInto(returnArray);
return returnArray;
}
}
端用远程地址?如果一定要的话,那就写socket吧,打开一个httpFile很容易的。