A. 如何用datareader讀取數據
1.創建資料庫連接。
2.創建sql命令並添加參數。
3.執行sql命令,並用sqldatareader讀取執行結果。
4.新建list<>實體集。
5.循環體,每從sqldatareader中讀取一行數據,就實例化一個實體,並將讀取到的那行數據的每個欄位值添入對應的屬性中去。最後將這個實體添加到實體集中。
6.結束循環,返回list<>實體集。
B. 安卓手機怎樣才能讀寫手機里的data文件夾
安裝RE文件管理器,進入/SYSTEM/DATA,或者你要找的那個DATA。長按,點許可權,把可讀,可寫,上面的勾打上就可以了。此步驟需要ROOT許可權。
C. 如何用java實現 讀取一個data類型文件 並顯示出來(隨便選擇一種類型txt或者word)
參考下面的程序,基本上已經包含了文件讀取的所有方式,這也是我之前學習的一個小程序,希望對你有所幫助~~~~
package com;
import java.io.BufferedReader;
public class TestFileInput {
private static final String FILENAME = "E:/test.txt";
private static final Logger logger = LoggerFactory.getLogger(TestFileInput.class);
public static void readByByte(String fileName) {
File file = new File(fileName);
InputStream in = null;
System.out.println("read file content by byte:");
try {
in = new FileInputStream(file);
int tempbyte = 0;
while ((tempbyte = in.read()) != -1) {
System.out.write(tempbyte);
}
in.close();
} catch (Exception e) {
logger.info("readByByte error!");
e.printStackTrace();
return;
}
try {
System.out.println("read by more byte:");
byte[] tempbytes = new byte[10];
int byteread = 0;
in = new FileInputStream(fileName);
while ((byteread = in.read(tempbytes)) != -1) {
System.out.write(tempbytes, 0, byteread);
}
} catch (Exception e) {
logger.info("read by more byte error!");
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
// do nothing
}
}
}
}
public static void readByChars(String fileName) {
File file = new File(fileName);
Reader reader = null;
System.out.println(" read by chars:");
try {
reader = new InputStreamReader(new FileInputStream(file));
int tempchar;
while ((tempchar = reader.read()) != -1) {
if (((char) tempchar) != '\r') {
System.out.println((char) tempchar);
}
}
reader.close();
} catch (Exception e) {
logger.info("read by chars error!");
e.printStackTrace();
}
System.out.println("read by more chars:");
try {
reader = new InputStreamReader(new FileInputStream(fileName));
char[] tempchars = new char[50];
int charread;
while ((charread = reader.read(tempchars)) != -1) {
if ((charread == tempchars.length) && (tempchars[tempchars.length - 1] != '\r')) {
System.out.print(tempchars);
} else {
for (int i = 0; i < charread; i++) {
if (tempchars[i] == '\r') {
continue;
} else {
System.out.print(tempchars[i]);
}
}
}
}
} catch (Exception e) {
logger.info("read by more chars error");
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void readByLines(String fileName) {
File file = new File(fileName);
BufferedReader reader = null;
System.out.println("read by line:");
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
while ((tempString = reader.readLine()) != null) {
System.out.println("line " + line + "is :" + tempString);
line++;
}
reader.close();
} catch (Exception e) {
logger.info("read by line error!");
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
// do nothing
}
}
}
}
public static void readByRandomAccess(String fileName) {
RandomAccessFile file = null;
System.out.println("read by randomAccessFile:");
try {
file = new RandomAccessFile(fileName, "r");
long length = file.length();
int beginIndex = (length > 4) ? 4 : 0;
file.seek(beginIndex);
byte[] bytes = new byte[10];
int byteread = 0;
while ((byteread = file.read(bytes)) != -1) {
System.out.write(bytes, 0, byteread);
}
} catch (Exception e) {
logger.info("read by randomAccess error");
} finally {
if (file != null) {
try {
file.close();
} catch (Exception e) {
// do nothing
}
}
}
}
public static void main(String[] args) {
readByByte(FILENAME);
readByChars(FILENAME);
readByLines(FILENAME);
readByRandomAccess(FILENAME);
}
}
D. 如何從datatable中讀取數據
label1.Text=dt.Rows[2][3].ToString();
列和行都是從0開始的,和二位數組一樣,同樣的調用方法。
E. android 一個apk如何訪問另外的apk的data目錄的
一般APK是無法訪問其它APK的data目錄,你的APK需要在源碼下編譯,獲得系統許可權後才能訪問。對應Android.mk 中添加 LOCAL_CERTIFICATE := platform。
F. 手機文件data不用root怎麼看
手機文件data不用root無法查看。
原因如下:
為了安全,大部分安卓非root用戶只有cache、system分區的讀取許可權,data分區無任何許可權,因此無法查看。但是部分軟體需要讀取系統信息如晶元型號,因此開放了system的讀取許可權。
但為了存儲數據,應用本身有data/data/該應用/文件夾的讀寫執行許可權。如果要讀取應用自身數據目錄,如終端模擬器的數據目錄,可以直接cd後ls列出。但是這個功能極少使用並且僅限終端類應用。
如果是想要提取data/app里的apk,可以用第三方軟體通過系統特殊介面獲取,無需root,但這樣不包含數據。方便分享apk包或備份。
G. android 怎麼拿到matadata
讀取application標簽下面的<meta-data>數據
ApplicationInfo appInfo =
context.getPackageManager().getApplicationInfo(context.getPackageName(),
PackageManager.GET_META_DATA);
String msg=appInfo.metaData.getString("data_Name");
H. 把數據獲取到datatable中.然後讀取datatable中的第一條,怎麼實現
將DataTable綁定到Repeter中不就可以了?
Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind()
I. android開發 怎麼把APP內部存儲data\data\files里的所有文件一條一條地讀出來
/data/data 目錄是需要root許可權才能查看的。
目前應用市場有非常多的一鍵ROOT工具,這里就不舉例了,功能基本都是一樣的,Root許可權的獲取方式:
1.用手機連接電腦,下載一鍵root工具。
2.下載成功後,打開一鍵ROOT軟體。會出現root准備,點擊下一步,正式開始root。
3.檢查root條件,要是需要文件備份的話,一定要備份後。點擊開始ROOT。
4.root正式開始,需要幾鍾左右時間,期間可能會重啟數次,root就會完成。
5.root完成後,就可以隨意刪除手機中的垃圾應用了包括系統應用。
當獲取root許可權後通過adb訪問 /data/data目錄:
adb shell 進入shell模式
su 切換到root用戶
chmod 777 /data/data 修改/data/data目錄的許可權為 777即可
exit 退出root用戶
cd /data/data 即可進入/data/data 目錄了
J. android如何讀寫/data/data文件
讀寫文件,和java中沒有區別的Filefile=newFIle("文件絕對路徑");注意這里的文件路徑,windows平台下盤符是c:d:e:等android是linux內核,路徑是/開頭的其它的就是InputStreamoutputStream沒什麼區別