요즘은 정말 스택오버플로우의 코드조각을 많이 참고합니다.

2000년에 만들어진 cos.jar를 보내드리고, 아파치 커먼스의 업로드 컴포넌트를 사용해 봤습니다.


https://github.com/kenu/oksample/tree/master/commons-fileup


/**
* code from: http://stackoverflow.com/questions/15432024/how-to-upload-a-file-using-commons-file-upload-streaming-api
*/
@WebServlet("/upload4")
public class UploadServlet4 extends HttpServlet {
        private static final long serialVersionUID = 1L;

        protected void doPost(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {
                PrintWriter out = response.getWriter();
                response.setHeader("Content-Type", "text/html");
                out.print("Request content length is " + request.getContentLength()
                                + "<br/>");
                out.print("Request content type is "
                                + request.getHeader("Content-Type") + "<br/>");
                boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                if (isMultipart) {
                        ServletFileUpload upload = new ServletFileUpload();
                        try {
                                FileItemIterator iter = upload.getItemIterator(request);
                                FileItemStream item = null;
                                String name = "";
                                InputStream stream = null;
                                while (iter.hasNext()) {
                                        item = iter.next();
                                        name = item.getFieldName();
                                        stream = item.openStream();
                                        if (item.isFormField()) {
                                                out.write("Form field " + name + ": "
                                                                + Streams.asString(stream) + "<br/>");
                                        } else {
                                                name = item.getName();
                                                System.out.println("name==" + name);
                                                if (name != null && !"".equals(name)) {
                                                        String fileName = new File(item.getName())
                                                                        .getName();
                                                        out.write("Client file: " + item.getName()
                                                                        + " <br/>with file name " + fileName
                                                                        + " was uploaded.<br/>");
                                                        File file = new File(getServletContext()
                                                                        .getRealPath("/" + fileName));
                                                        FileOutputStream fos = new FileOutputStream(file);
                                                        long fileSize = Streams.copy(stream, fos, true);
                                                        out.write("Size was " + fileSize + " bytes <br/>");
                                                        out.write("File Path is " + file.getPath()
                                                                        + "<br/>");
                                                }
                                        }
                                }
                        } catch (FileUploadException fue) {
                                out.write("fue!!!!!!!!!");
                        }
                }
        }
}


http://eclipsecolorthemes.org/


딱 마음에 들지는 않지만 분위기 전환용으로는 괜찮습니다.

Color Theme 플러그인과 EPF(Eclipse Preference File)로 변경가능합니다.

EPF로 다운로드 받은 경우 File > Import 를 통해서 General > Preferences를 통해서 가져올 수 있습니다.


플러그인을 통해서 변경하면 편합니다.

http://eclipse-color-theme.github.com/update 주소를 Help > Install New Software... 메뉴를 통해서 추가하면 됩니다.


컬러 테마가 설치되면 Preferences에서 color 검색으로 쉽게 볼 수 있습니다. 다양한 세팅이 있습니다. Aptana, Notepad++, Sublime Text 2 등 유명한 편집기 테마가 목록에 있습니다.


이점이 아쉬운데, 이크립스 전체는 아니고, 편집기 영역만 변경됩니다. Ctrl+M으로 전체화면으로 키워서 편집하면 괜찮습니다.


문제는 파일 비교할 때인데, 참 난감할 수 있습니다.


가끔 분위기 전환용으로 추천합니다.


이클립스 코드 네비게이션 단축키

* 새로 만들기 Ctrl+N
* Quick Access Ctrl+3
* 코드 자동완성 Ctrl+Space
* import 정리 Ctrl+Shift+O
* 빨리 수정 Ctrl+1
* 한 줄 삭제 Ctrl+D
* 코드 정렬 Ctrl+Shift+F

* 선언한 곳으로 F3 또는 Ctrl+클릭
* 이전 위치로 Alt+←
* 파일 아웃라인 Ctrl+O
* 상속 구조 Ctrl+T
* 선택 문자 찾기 Ctrl+K
* 행번호로 이동 Ctrl+L
* 파일명으로 찾기 Ctrl+Shift+R
* 프로젝트 텍스트 검색 Ctrl+H

* 실행 Ctrl+F11
* 단축키 목록 Ctrl+Shift+L
* 단축키 설정 Ctrl+Shift+L 두 번




백그라운드 컬러

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/bg"
>
...
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">샘플</string>
    <color name="bg">#FFFFFF</color>
</resources>


화면 전환 애니메이션
<?xml version="1.0" encoding="utf-8"?>

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
       android:interpolator="@android:anim/accelerate_interpolator"
       android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="100" />

code from: http://developerlife.com/tutorials/?p=343


related: http://developer.android.com/guide/topics/resources/available-resources.html#tweenedanimation


// 이미지 롤링

idx = ++idx % 8;
image.setImageResource(R.drawable.sample_0 + idx);


// 이미지 파일명으로 세팅

idx = ++idx % 8;
int resID = getResources().getIdentifier("sample_" + idx , "drawable", getPackageName());
image.setImageResource(resID);


sample:


참고: 


DHCP 관련 에러를 만났을 때 대처법입니다.

"Unable to start the Genymotion virtual device. 

The Genymotion Virtual device could not obtain an IP address.

For an unknown reason, VirtualBox DHCP has not assigned an IP address to virtual device. Run the VirtualBox software to check for issues."

먼저 설치되어 있던 VirtualBox의 글로벌 환경설정(cmd+,)에서 네트워크 > 호스트 전용 네트워크의 DHCP 서버를 체크해야 합니다.

vboxnet0 항목을 선택하고 우측에 드라이버 아이콘을 클릭합니다.


DHCP 서버를 체크해서 올려야 Genymotion 가상 디바이스가 IP를 획득할 수 있게 됩니다.




참고: https://cloud.genymotion.com/page/faq/#collapse-nostart

맥에서 기존에 설정된 것 때문에 삽질하다가 연결을 드디어 했습니다.

첫 사용 소감.

"개빠르다"

개- 접두사가 붙은 것은 강조입니다. 정말 빠르네요. 실행만 빠른 것이 아니라 apk옮겨가는 속도도 굉장합니다.


40만 다운로드가 나올 수 밖에 없습니다.

http://www.genymotion.com/


만약 본격적으로 안드로이드 개발을 한다면 정말 연단위 99유로 라이선스를 결제해 버릴만한 품질입니다.

블로그를 살펴보면 버그가 있다고 하지만, 디바이스를 사용하는 것 이상의 개발 속도가 나올 것 같습니다.


Galaxy Nexus 4.1.1 API 16 720x1280 이미지를 실행한 에뮬입니다. 우측에 부가 기능 버튼이 있습니다. 아이폰의 시뮬레이터 이상의 속도로 느껴집니다.

AVD 이제 Bye Bye!!!!!!!

http://www.genymotion.com/


1. 회원가입 필요, 무료 가능



2. virtualBox 설치 또는 OS별 Genymotion 다운로드

IntelliJ와 Eclipse 플러그인 지원


3. 안드로이드 이미지 선택 및 다운로드

4. 이클립스 genymotion 플러그인 설치 http://plugins.genymotion.com/eclipse

5. 빠른 안드로이드 에뮬 경험



참고: 

우분투에서 Genymotion : http://byneonkid.tistory.com/40

맥에서 Genymotion : http://www.kmshack.kr/347

버전업시 주의할 점: http://kingorihouse.tumblr.com/post/67355210627/genymotion-2-0-1

윈도우에서 http://huhspunk.tistory.com/archive/201310

윈도우의 경우 이슈가 참 많네요. 한글입력기도 수정해야 돌고,



코드 곳곳에 비슷한 패턴으로 들어가 있는 부가작업: 로깅, 트랜잭션, 등

이 코드를 한 클래스에 모아놓음 : Advice

그리고 남겨진 순수한 코드 : Core Concern



이제 Advice와 핵심코드를 엮어주는 일: Weaving

어떤 패턴으로 엮어줄 것인가: PointCut



엮어줄 시점을 정하는 것: JoinPoint

핵심코드 실행시점 전에 Advice를 실행 : before

핵심코드 실행시점 전과 후에 Advice를 실행 : around

핵심코드 실행시 예외 발생 Advice를 실행 : throw

...


XML

<bean id="adviceUsingXML" class="egovframework.rte.fdl.aop.sample.AdviceUsingXML" />

<bean id="concernSample" class="egovframework.rte.fdl.aop.sample.ConcernSample" /> 

<aop:config>
  <
aop:pointcut id="targetMethod" expression="execution(* egovframework.rte.fdl.aop.sample.*Sample.*(..))" /> 

  <aop:aspect ref="adviceUsingXML">

    <aop:before pointcut-ref="targetMethod" method="beforeTargetMethod" /> 

    <aop:after-returning pointcut-ref="targetMethod" method="afterReturningTargetMethod" returning="retVal" /> 

    <aop:after-throwing pointcut-ref="targetMethod" method="afterThrowingTargetMethod" throwing="exception" />

    <aop:after pointcut-ref="targetMethod" method="afterTargetMethod" /> 

    <aop:around pointcut-ref="targetMethod" method="aroundTargetMethod" />

  </aop:aspect>

</aop:config>

code from: egovframe textbook 


추천예제: 최범균님 스프링3.0 서적 chap01 예제

http://www.kame.co.kr/pds1.html?main=main_pds [G220] 링크




+ Recent posts