블로그 이미지
박공명

카테고리

분류 전체보기 (99)
된장 (7)
Dev (60)
꼐..꼐임 (6)
식탐 (18)
우리 (0)
Etc (8)
개인자료 (0)
Total
Today
Yesterday

영문 숫자 조합의 문자열을 바이트별로 잘라야할 일이 생겼다.


인터넷 검색결과 보통 타이틀 길이를 제한하기위한 용도로만 사용하기에 어쩔수없이 새로만듬.


원하는 바이트의 배열 숫자만큼 그리고 길이가 초과하면 빈칸으로 채운 list를 반환한다.



결과 :

INFO : com.x2trade.base.controller.javaTest - 하이요1

INFO : com.x2trade.base.controller.javaTest - 하이요2

INFO : com.x2trade.base.controller.javaTest - 하이요3

INFO : com.x2trade.base.controller.javaTest - 하이요4

INFO : com.x2trade.base.controller.javaTest - 하이요5

INFO : com.x2trade.base.controller.javaTest - 

INFO : com.x2trade.base.controller.javaTest - 


소스 :

public void testSampleView()

{

String str = new String("하이요1하이요2하이요3하이요4하이요5");

List<String> strList = cutString(str,10,10,10,10,10,10,10);

for(String a : strList) {

logger.info(a);

}

}        

public List<String> cutString(String str,int...cuttingBytes) {

List<String> rtnList = new ArrayList<String>();

if(str == null) str = "";

int maxLength = str.length();

int i=0;

for(int cutBytes : cuttingBytes) {

StringBuffer sb = new StringBuffer("");

if(i>maxLength) {

rtnList.add("");

break;

}

for(;i<maxLength;i++) {

if(sb.toString().getBytes("utf-8").length + str.substring(i, i+1).getBytes("utf-8").length > cutBytes) break;

sb.append(str.substring(i, i+1));

}

rtnList.add(sb.toString());

}

return rtnList;

}

'Dev > Java' 카테고리의 다른 글

자바 컴파일 클래스패스 지정  (0) 2010.04.01
java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp upload  (0) 2010.03.24
ftp 파일삭제.  (0) 2010.03.24
Posted by 박공명
, |

별거 아니면서도 자주 안쓰면서도 종종 써서 빡치게하는 POI


다음부터라도 편하게 사용하기위하여 정리를 해야겟다.


Maven 기본이져 ?


        <dependency>

   <groupId>org.apache.poi</groupId>

   <artifactId>poi</artifactId>

   <version>3.9</version>

</dependency> 

 

 <dependency>

   <groupId>org.apache.poi</groupId>

   <artifactId>poi-ooxml</artifactId>

   <version>3.9</version>

</dependency>


두개를 추가함으로서 HSSF , XSSF를 사용할수 있게된다


전자는 옜날버젼 후자는 통합문서를 사용할수있게한다.


두개를 같이 사용하기 위하여 파일 확장자를 확인하여 구분하도록 한다


String fileName = File.getOriginalFilename();

logger.info("fileName : {}",fileName);

String fileExt = fileName.substring(fileName.lastIndexOf(".")+1);

logger.info("fileExt : {}",fileExt);

POIFSFileSystem fs = null;

Workbook workBook = null;

if(fileExt.equals("xls")) {

fs = new POIFSFileSystem(File.getInputStream());

workBook = new HSSFWorkbook(fs);

} else if(fileExt.equals("xlsx")) {

workBook = new XSSFWorkbook(File.getInputStream());

}

Sheet sheet = workBook.getSheetAt(0);

int rows = sheet.getPhysicalNumberOfRows();

for(int r=0; r<rows; r++){

Row row = sheet.getRow(r);

String storeNo = "";

String storeName = "";

if(row != null){

for(int c=0; c<2; c++){

Cell cell = row.getCell(c);

if(cell != null) {

switch(cell.getCellType()) {

case HSSFCell.CELL_TYPE_NUMERIC:

if(c == 0) {

storeNo = String.valueOf((int)cell.getNumericCellValue());

} else if(c == 1) {

storeName = String.valueOf(cell.getNumericCellValue());

}

break;

case HSSFCell.CELL_TYPE_STRING:

if(c == 0) {

storeNo = cell.getStringCellValue();

} else if(c == 1) {

storeName = cell.getStringCellValue();

}

break;

case HSSFCell.CELL_TYPE_BLANK:

throw new Exception();

}

}

}

logger.info("{} \t {}",storeNo,storeName);

}

}

Posted by 박공명
, |


생강빵 외 최신버젼(java6)

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
 
프로요 하위버젼(java5)
 
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse"
$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk
 
필요한 패키지들
 
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev 
  lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev
 
64빗 시스템에서 32빗환경을 구축하기위하여 필요한 패키지
 
$ sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
 
 usb 설정
 
root권한으로 /etc/udev/rules.d/51-android.rules  파일을 만든다.
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
# adb protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
들입다 복사해다 붙여넣는 병신은 없길바래.
 
소스 다운로드환경
 
$ mkdir ~/bin $ PATH=~/bin:$PATH
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
세세한 파일경로는 입맛대로 바꾼다.
 
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
 
마스터 체크아웃을 가져올때
 
$ repo init -u git://android.git.kernel.org/platform/manifest.git
특정 브랜치를 가져올떈 -b옵션을 사용하자
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
 
파일가져오기
 
$ repo sync
 
태그작업 패스
 
빌드하기
 
최초 환경설정
$ source build/envsetup.sh
or
$ . build/envsetup.sh
. 왜찍는지 궁금하지? ㅋ ㅋ
 
타겟설정
 
$ lunch full-eng
argument 는 DEVICE-BUILDTYPE
 
DeviceBuild configuration
crespofull_crespo-userdebug
crespo4gfull_crespo4g-userdebug
passionfull_passion-userdebug
sapphirefull_sapphire-userdebug
dreamfull_dream-userdebug
 
BuildtypeUse
userlimited access; suited for production
userdebuglike "user" but with su access; preferred for debugging
engunrestricted access
 
대망의 빌드
몇개의 스레드를 사용해서 병렬빌드할지 정함.
make -j4
 
 
adb,fastboot build
$make adb fasboot
 
fastboot mode booting
DeviceKeys
crespoPress and hold Volume Up, then press and hold Power
crespo4gPress and hold Volume Up, then press and hold Power
passionPress and hold the trackball, then press Power
sapphirePress and hold Back, then press Power
dreamPress and hold Back, then press Power
 
Unlocking the bootloader
$ fastboot oem unlock
 
언락시 넥서스원은 복구가 불가능하다고 나와있네
넥서스s , 4g 는 다음명령어로 가능
$fastboot oem lock
 
Flashing a device
사용자 데이터는 일반적으로 호환되지않기때문에 싹다 지우는게 좋다
$ fastboot erase cache
$ fastboot erase userdata
 
그리고 한방에 싹올린다
#fastboot flashall
 
crespo,4g,sapphire는 단일명령으로 수행가능하다(넥서스원passion은 안됨)
$fastboot -w flashall
 
 
 
 사실 공식홈 나온대로하면 아무 무리 없다.
http://source.android.com/source/initializing.html

'Dev > Android' 카테고리의 다른 글

android source 브랜치 가져오기  (0) 2011.05.20
android fastboot 사용하기  (0) 2011.05.20
Real 3D - 단순 이미지 3D 구현  (0) 2011.04.20
Real 3D 개요  (0) 2011.04.19
LG Real 3D SDK  (1) 2011.04.13
Posted by 박공명
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함