導航:首頁 > 配伺服器 > tomcat伺服器如何允許下載

tomcat伺服器如何允許下載

發布時間:2023-06-16 06:21:12

⑴ 如何配置Tomcat伺服器環境

一、安裝JDK和Tomcat

1,安裝JDK:直接運行jdk-7-windows-i586.exe可執行程序,默認安裝即可。

備註:路徑可以其他盤符,不建議路徑包含中文名及特殊符號。

2、安裝Tomcat:直接解壓縮下載文件「apache-tomcat-7.0.33-windows-x86.zip」到C盤下。安裝路徑建議修改為:c: omcat。

備註:如下載的是可執行文件,雙擊運行,默認安裝即可。

android 如何從tomcat伺服器上下載文件

//下載
private InputStream FileDownload(String url_str) throws Exception{

URL url = new URL(url_str);
// 創建連接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(3000);
conn.setConnectTimeout(3000);
conn.connect();

// 獲取文件大小
length = conn.getContentLength();
// 創建輸入流
InputStream is = conn.getInputStream();

return is;
}
//保存
private void FileSave(String filename,InputStream is,int length) throws Exception{

File file = new File(mSavePath);
// 判斷文件目錄是否存在
if (!file.exists())
{
file.mkdir();
}
File apkFile = new File(mSavePath, filename);
FileOutputStream fos = new FileOutputStream(apkFile);
int count = 0;
// 緩存
byte buf[] = new byte[1024];
// 寫入到文件中
do
{
int numread = is.read(buf);
count += numread;
// 計算進度條位置
progress = (int) (((float) count / length) * 100);
// 更新進度
mHandler.sendEmptyMessage(DOWNLOAD);
if (numread <= 0)
{
// 下載完成
mHandler.sendEmptyMessage(DOWNLOAD_FINISH);
break;
}
// 寫入文件
fos.write(buf, 0, numread);
} while (!cancelUpdate);// 點擊取消就停止下載.
fos.close();
}

/**
* 安裝APK文件
*/
private void installApk()
{
File apkfile = new File(mSavePath, mHashMap.get("name"));
if (!apkfile.exists())
{
return;
}
// 通過Intent安裝APK文件
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file://" + apkfile.toString()), "application/vnd.android.package-archive");
mContext.startActivity(i);
}

閱讀全文

與tomcat伺服器如何允許下載相關的資料

熱點內容
思科路由器命令手冊 瀏覽:26
android獲得當前activity 瀏覽:831
python入門迷宮 瀏覽:69
Python打折代碼不含商品 瀏覽:220
把多個Word合成一個pdf 瀏覽:356
aes演算法描述 瀏覽:899
新手機壓縮包在哪 瀏覽:781
java抽獎程序源碼 瀏覽:700
汽車壓縮機又叫 瀏覽:95
android讀取data文件 瀏覽:874
紅旗智聯app怎麼跟h5車子連接 瀏覽:139
材料化學pdf 瀏覽:114
伺服器機房都有什麼東西 瀏覽:370
最近長陰短柱量能副圖指標源碼 瀏覽:647
python字元串去除後四位 瀏覽:167
捷速pdf編輯器破解版 瀏覽:726
大帶寬伺服器怎麼租 瀏覽:299
籃球程序員單身難嗎 瀏覽:877
一接到命令就 瀏覽:488
挖幣伺服器是什麼 瀏覽:524