|
|
|
[ขอความช่วยเหลือค่ะ] ช่วยแก้โค้ด java ให้เป็นโค้ดของ Android ที่เขียนบน Eclipse ให้หน่อยค่ะ |
|
|
|
|
|
|
|
Code (Android-Java)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testfile;
import java.io.*;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author nakamura
*/
public class TestFile {
/**
* @param args the command line arguments
*/
public java.util.Vector<String> lsword = new java.util.Vector<String>();
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, IOException, SQLException {
// TODO code application logic here
TestFile bot = new TestFile();
String Folder = "D:\\excemple";
//String Folder = "D:/Work/bankingbot/bankingfile";
//System.out.println(Folder);
List list = bot.listfilname(Folder);
//List lsword = new ArrayList<String>();
for (Object fileName : list) {
// get data from log file
String filename = fileName.toString();
String fullpathname = Folder + "/" + filename;
//System.out.println(filename);
//if (!bot.checkvalidtable(filename)) {
// read and insert to database
bot.readfile(fullpathname,filename);
}
//bot.output();
String aaa[][] = bot.word_split(); //
for(int a=0;a<aaa.length;a++){
for(int b=0;b<33;b++){
String wd = aaa[a][2];
System.out.println(wd);
}
}
//System.out.println(aaa.length);
// TODO code application logic here
}
public void output(){
for(String aa : lsword){
//System.out.println(aa);
}
}
public String[][] word_split(){
int y = 20;
String art[][] = new String[lsword.size()][y];
for(int i=0;i<lsword.size();i++){
String word = lsword.get(i);
String art_word[] = word.split(",");
for(int j=0;j<art_word.length;j++){
art[i][j] = art_word[j];
}
}
return art;
}
public static List listFilesForFolder(final File folder) {
List data = new ArrayList();
for (final File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry);
} else {
data.add(fileEntry.getName());
}
}
return data;
}
public List listfilname(String path) {
final File folder = new File(path);
List ls = listFilesForFolder(folder);
return ls;
}
private void readfile(String pathfilename,String filename) throws FileNotFoundException, IOException, SQLException {
File file = new File(pathfilename) ;
FileInputStream fis = new FileInputStream(file) ;
InputStreamReader isr = new InputStreamReader(fis, "windows-874") ;
BufferedReader br = new BufferedReader(isr) ;
//BufferedReader br = new BufferedReader(new FileReader(file)) ;
String temp ;
while ((temp = br.readLine()) != null){
temp = filename+","+temp.trim();
lsword.add(temp);
}
}
}
Tag : Mobile, Android, Mobile
|
ประวัติการแก้ไข 2014-11-21 22:23:23
|
|
|
|
|
Date :
2014-11-21 22:22:12 |
By :
numtok |
View :
964 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code นี้มันทำอะไรครับ คือบาง Class มันใช้กับ Android ไมไ่ด้น่ะครับ
|
|
|
|
|
Date :
2014-11-22 08:12:22 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|