搜尋此網誌

windows常用命令

[ 群組原則 ]
開始 → 執行 → gpedit.msc

[ 惡意軟體移除工具 ]
開始 → 執行 → mrt

[ 機碼 ]
開始 → 執行 → regedit

[ 系統設定公用程式 ]
開始 → 執行 → msconfig

[ 控制client端所有網路設備 ]
開始 → 執行 → cmd → ipconfig
開始 → 執行 → cmd → ipconfig/all

[ 顯示封包經過的路由器的IP位址 ]
開始 → 執行 → cmd → tracert (網址或IP)

2011年9月14日 星期三

POI Excel


//寫在 try catch

List<String> filelist = getExcelFile(uploadDirectory, fileName);//解壓縮,並把檔案名稱塞入List for(int data=0; data<filelist.size(); data++) { System.out.println("目前讀取 "+(String)filelist.get(data)); POIFSFileSystem pfs = new POIFSFileSystem(new FileInputStream((String)filelist.get(data))); HSSFWorkbook wb = new HSSFWorkbook(pfs); //取sheet System.out.println("共 "+wb.getNumberOfSheets()+" sheet"); for(int sheets=0; sheets<wb.getNumberOfSheets(); sheets++){ HSSFSheet sheet1 = wb.getSheetAt(sheets); HSSFRow row = null; //取row System.out.println("共 "+sheet1.getLastRowNum()+" row");//(從0算起) System.out.println("PhysicalNumber共 "+sheet1.getPhysicalNumberOfRows()+" row");//(從1算起) for(int rowNum=0; rowNum<sheet1.getPhysicalNumberOfRows(); rowNum++) { row = sheet1.getRow(rowNum); //從第6Row開始讀取 // if( (null == row) || ((6-1)>rowNum) ){ // continue; // } //取cell // int tempCT = 0;//沒有隱藏cell的順序 // System.out.println("第 "+String.valueOf(rowNum+1)+" row "+String.valueOf(Integer.valueOf(row.getLastCellNum()))+" cell"); System.out.println("共 "+row.getLastCellNum()+" cell"); for(int cellNum=0; cellNum<row.getLastCellNum(); cellNum++) { // //第1Cell跳過 // if( (1-1)==cellNum ) { // ++tempCT; // continue; // } // //第4Cell,前一Cell,ID沒有取到值,跳下一列 // if( (4-1)==cellNum ) { // if("".equals(personID)) { // break; // } // } // //隱藏欄,跳過 // if(sheet1.isColumnHidden(cellNum)) { // continue; // } HSSFCell cell = row.getCell(cellNum); if(null != cell) { //取出資料 String value = ""; if(cell.CELL_TYPE_NUMERIC == cell.getCellType()) { value = String.valueOf( new Double(cell.getNumericCellValue()).longValue() ); } else if(cell.CELL_TYPE_STRING == cell.getCellType()) { value = cell.getStringCellValue().trim();//去掉值前後半形空白 } System.out.println(value); } } } } }
//=======================================================================

//讀取
POIFSFileSystem pfs = new POIFSFileSystem(new FileInputStream((String)filelist.get(data)));
HSSFWorkbook wb = new HSSFWorkbook(pfs);
//取sheet
for(int sheets=0; sheets<wb.getNumberOfSheets(); sheets++){
HSSFSheet sheet1 = wb.getSheetAt(sheets);
HSSFRow row = null;
//取row
//取row System.out.println("共 "+sheet1.getLastRowNum()+" row");//(從0算起) System.out.println("PhysicalNumber共 "+sheet1.getPhysicalNumberOfRows()+" row");//(從1算起) for(int rowNum=0; rowNum<sheet1.getPhysicalNumberOfRows(); rowNum++) {
row = sheet1.getRow(rowNum);
//從第2Row開始讀取
if( (null == row) || ((2-1)>rowNum) ){
continue;
}

// System.out.println("第 "+String.valueOf(rowNum+1)+" row "+String.valueOf(Integer.valueOf(row.getLastCellNum()))+" cell"); System.out.println("共 "+row.getLastCellNum()+" cell"); for(int cellNum=0; cellNum<row.getLastCellNum(); cellNum++) {
HSSFCell cell = row.getCell(cellNum);
if(null != cell) {
//取出資料
if(cell.CELL_TYPE_NUMERIC == cell.getCellType()) {
System.out.println("數cellType= " +cell.getCellType()+ " ,cellValue= " + String.valueOf( new Double(cell.getNumericCellValue()).longValue() ));
} else if(cell.CELL_TYPE_STRING == cell.getCellType()) {
System.out.println("文cellType= " +cell.getCellType()+ " ,cellValue= " + cell.getStringCellValue().replace(" ", "").trim());//先去掉全形空白,再去掉半形空白
}
}
}
}

}
//=======================================================================
//寫出

2011年9月9日 星期五

處理前端多個檔案上傳


//Parse the request
// List<String> fileDescList = new ArrayList<String>();
List<String> fileNameList = new ArrayList<String>();
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
   FileItemStream item = iter.next();
   String name = item.getFieldName();
   InputStream stream = item.openStream();
   if (item.isFormField()) {
       String value = Streams.asString(stream);
out.println(name + "=" + value+"<br>");
//        if ("filedesc".equals(name)) {
//            fileDescList.add(value);
//        }
   } else {
out.println("File field " + name + " with file name " + item.getName() + " detected.");
       // Process the input stream
       String fieldName = item.getFieldName();
       String fileName = item.getName();
       String contentType = item.getContentType();
out.println("fieldName="+fieldName+"<br>");
out.println("fileName="+fileName+"<br>");
out.println("contentType="+contentType+"<br>");
       if (fileName != null && !"".equals(fileName)) {
           fileName= FilenameUtils.getName(fileName);
out.println("fileName saved="+fileName+"<br>");
           fileNameList.add(fileName);
           File uploadedFile = new File(saveDirectory, fileName);
           FileOutputStream uploadedFileStream =
               new FileOutputStream(uploadedFile);
           Streams.copy(stream, uploadedFileStream, true);
       }
   }
}

String msg[] = null;
for (int i = 0; i < fileNameList.size(); i++) {
//    String fileDesc = fileDescList.get(i);
   String fileName = fileNameList.get(i);
// out.println(fileName+":"+fileDesc+"<br>");

String path = saveDirectory + "\\" + fileName;
String fileType = request.getParameter("fileType");//檔案類型
//System.out.println(fileType);

if(fileType.equals("0")) {
msg = new ImportExcelB().insertData_ADDR(path);
} else if(fileType.equals("1")) {
msg = new ImportExcelB().insertData_GOV99(path);
}
}

2011年9月1日 星期四

SQL Exception

起因:
無法解析 equal to 作業中 "Chinese_Taiwan_Stroke_CS_AS" 與 "Chinese_Taiwan_Stroke_CI_AS" 之間的定序衝突。

解決:

2011年8月31日 星期三

Java Log


common.Logger logger = common.Logger.getLogger(xxx.class);
logger.debug("Hello Log4j, this is debug message");


private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(xxx.class);
log.debug("Hello Log4j, this is debug message");

2011年8月6日 星期六

Line Numbers

SQL Server Management Studio
Tools → Options → Text Editor → All Languages → (right panel)checkbox against Line numbers。

Eclipse
Editor(left) right mouse → Show Line Numbers。

2011年8月1日 星期一

Eclipse安裝Subversion

參考資料1 - Eclipse Subversive - Documentation

參考資料2 - subclipse: Download and Install

參考資料3 - Version Control with Subversion

取消 Fn+Space 功能鍵

移除「ThinkPad FullScreen Magnifier」的軟體,這個Fn+Space鍵就沒有作用了。

MS SQL Server 不能連線

Network Error IOException: Connection refused: connect
or
Network error IOException: Connection timed out: connect

Causes:
  • The hostname or port number in the config.ini file is incorrect.
  • A Firewall is blocking the SQL Server port.
  • Your version of SQL Server 2000 is too old to support the way Coretalk connects to database.
  • The SQL Server service is not started.
Solutions:
  • Double check to make sure that the hostname and port number is correct and change it if necessary.
  • Open the TCP/IP port for the port number specified in the config.ini file. You would have to first find out what firewall software the client uses and then add an exception to it’s rules for that specific port. There are too many free and commercial firewall systems to list instructions for all of them.
  • This is very unlikely to happen. It will only happen if you install on an existing instance of SQL Server 2000 that has not been updated to SP4. If you can’t connect and everything else seems correct, make sure that it is SP4. If not, download the SP4 update from the Microsoft website and install that first.
  • Start the SQL Server service. You should also go into the service properties and make sure that the startup properties is set so that the service starts automatically.

滑鼠右鍵刪除Subversion的隱藏目錄 .svn&_svn

註冊檔(Registry File)可以設定檔案總管在目錄上的右鍵選單多一個 Delete SVN Folders 功能,你只要在目錄上按下右鍵,然後選擇 
Delete SVN Folders 就會將該目錄以及所有子目錄下的所有 .svn 目錄給刪除掉。
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /k \"TITLE Removing SVN Folders in %1 && FOR /r \"%1\" %%f IN (.svn _svn) DO RD /s /q \"%%f\" \""
 
資料來源