在Android 中實現多引數檔案和資料上傳

2021-07-04 07:35:37 字數 1207 閱讀 5977

上**:

/**

* 可傳入多張和引數

* * @param actionurl

* 傳送位址

* @param params

* 文字引數

* @param files

* 檔案引數

* @return

* @throws ioexception

*/public static string mulpost(string actionurl, mapparams,

mapfiles) throws ioexception

dataoutputstream outstream = new dataoutputstream(

conn.getoutputstream());

outstream.write(sb.tostring().getbytes());

// 傳送檔案資料

if (files != null)

for (map.entryfile : files.entryset())

is.close();

outstream.write(linend.getbytes());

}// 請求結束標誌

byte end_data = (prefix + boundary + prefix + linend).getbytes();

outstream.write(end_data);

outstream.flush();

inputstream is = conn.getinputstream();

inputstreamreader isr = new inputstreamreader(is, "utf-8");

bufferedreader br = new bufferedreader(isr);

result = br.readline();

outstream.close();

conn.disconnect();

return result;

}

方法就是這樣的。

使用時可封裝在自己的類裡直接呼叫即可,記得加網路訪問和讀取系統檔案的許可權哦。

由於上傳是耗時操作,必須得要弄在另乙個執行緒中呼叫才可以。

在QML應用中實現threading多工

在這個例子中,我們將介紹如何在qml應用中使用qml語言提供的threading功能,實現多工。更多的閱讀在 我們使用ubuntu sdk來建立以個最基本的qml專案 import qtquick 2.0 import ubuntu.components 1.1 brief mainview wit...

easyui的filebox元件實現多檔案上傳

html easyui panel title 上傳檔案 style width 100 padding 30px 70px 50px 70px userform name userform enctype multipart form data method post margin bottom ...

C C 實現多引數函式程式設計

在c c 中,我們經常會需要實現類似printf這樣的函式,即函式的引數個數是不定的,這個時候就需要用到我們這篇文章講到的方法啦。首先,我們要知道這種函式,如何來定義。比如我想實現乙個函式能夠支援 fun d 1 那麼這個函式的定義實際上如下 voidfun constchar fmt,其中.的意思...