import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; public class CommandExtractor { public static void main(String[] args) throws Exception { File file = new File(args[0]); if(file.exists()) { BufferedReader inFile = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8")); String sLine = null; while( (sLine = inFile.readLine()) != null ) { if (sLine.indexOf("command") > 0) { System.out.println(sLine.substring(57)); } } } } }
Programming
- java - readLine 2013.02.04
- jstl 2012.10.28
- PNG Image Base64 Encoder / Decoder 2012.10.15
- ios - c++ static library xcode에서 사용하기 2012.09.13
- ios - xcode 초간단 예제 2012.09.12
- 안드로이드 - 정적 라이브러리 NDK 빌드 2012.09.07
- Eclipst CDT - 정적(Static) 라이브러리 만들기 2012.09.06
- player 2012.09.03
java - readLine
jstl
출처 : Spring MVC Checkbox And Checkboxes Example
CodeData.java
public class CodeData { private int itemValue; private String itemLabel; public CodeData(int itemValue, String itemLabel) { super(); this.itemValue = itemValue; this.itemLabel = itemLabel; } public int getItemValue() { return itemValue; } public void setItemValue(int itemValue) { this.itemValue = itemValue; } public String getItemLabel() { return itemLabel; } public void setItemLabel(String itemLabel) { this.itemLabel = itemLabel; } }
라디오버튼
List<CODEDATA> typeList = new ArrayList<CODEDATA>(); typeList.add(new CodeData(1, "남자")); typeList.add(new CodeData(2, "여자")); modelMap.addObject("typeList", typeList);
<form:radiobuttons path="gender" items="${typeList}" itemValue="itemValue" itemLabel="itemLabel"/>
셀렉트박스
<form:select path="template_id" style="width: 200px; display:none"> <form:options items="${listTemplate}" itemLabel="name" itemValue="tid" /> </form:select>
form action url
출처 : Spring MVC: Relative URL problems<spring:url var = "action" value='/ruleManagement/save' ... /> <form:form action="${action}" method="post">
- end -
PNG Image Base64 Encoder / Decoder
PNG Image Base64 Encoder / Decoder
Sencha touch에 툴바용 이미지를 css에 사용하려고 만들어본 툴입니다.
한시간만에 만든것이라 버그가 많습니다.
배포는 자유지만 출처는 밝혀주세요
ios - c++ static library xcode에서 사용하기
출처
Apple LLVM compilerと無名カテゴリ
Building static C++ lib for use with Objective-c app in Xcode 4
static library 빌드 및 라이브러리 사용 어플리케이션 통합 디버깅하기 - 아이폰 4.x
Using C/C++ static libraries from iPhone ObjectiveC Apps
Xcode architectureエラー
objective c에서 STL 사용하기
아이폰에서 C로 된 정적 라이브러리 사용하기
Xcode 4.0 에서 c로 된 static library link error 조치
testlib.h 파일
/* * testlib.h * * Created on: 2012. 9. 6. * Author: bluexmas */ #ifndef LIBTEST_H_ #define LIBTEST_H_ #if defined(_WIN32) || defined(__WIN32__) #define DLL_CALLCONV __stdcall #ifdef LIBTEST_EXPORTS #define DLL_API __declspec(dllexport) #else #define DLL_API __declspec(dllimport) #endif // LIBTEST_EXPORTS #else // try the gcc visibility support (see http://gcc.gnu.org/wiki/Visibility) #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) #ifndef GCC_HASCLASSVISIBILITY #define GCC_HASCLASSVISIBILITY #endif #endif // __GNUC__ #define DLL_CALLCONV #if defined(GCC_HASCLASSVISIBILITY) #define DLL_API __attribute__ ((visibility("default"))) #else #define DLL_API #endif #endif // WIN32 / !WIN32 DLL_API const char *DLL_CALLCONV get_version(void); #endif /* LIBTEST_H_ */
testlib.cpp 파일
/* * testlib.cpp * * Created on: 2012. 9. 6. * Author: bluexmas */ #include "testlib.h" const char* get_version() { return "testlib ver 0.2"; }
makefile.iphone-debug 파일
RM := rm -rf GCC_VERSION = 4.2 IPHONEOS_DEPLOYMENT_TARGET = 5.1 MACOSX_DEPLOYMENT_TARGET = 10.8 PLATFORM_SIM = iPhoneSimulator PLATFORM_PHONE = iPhoneOS ARCH_SIM = i386 ARCH_PHONE = armv7 TOOLCHAIN=/Volumes/Mac/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin DEVROOT=/Volumes/Mac/Applications/Xcode.app/Contents/Developer PLATFORM_SIM_DEVELOPER_BIN_DIR = $(DEVROOT)/Platforms/$(PLATFORM_SIM).platform/Developer/usr/bin PLATFORM_PHONE_DEVELOPER_BIN_DIR = $(DEVROOT)/Platforms/$(PLATFORM_PHONE).platform/Developer/usr/bin SDKROOT_SIM = $(DEVROOT)/Platforms/$(PLATFORM_SIM).platform/Developer/SDKs/$(PLATFORM_SIM)$(IPHONEOS_DEPLOYMENT_TARGET).sdk SDKROOT_PHONE = $(DEVROOT)/Platforms/$(PLATFORM_PHONE).platform/Developer/SDKs/$(PLATFORM_PHONE)$(IPHONEOS_DEPLOYMENT_TARGET).sdk IDIR=./inc CLANG=$(TOOLCHAIN)/clang CLANGFLAGS_SIM=-x objective-c-header -O0 -g3 -Wall -c -fmessage-length=0 -DDEBUG=1 CLANGFLAGS=-x objective-c -O0 -g3 -Wall -c -fmessage-length=0 LIBTOOL=$(TOOLCHAIN)/libtool SDIR=./src ODIR=./lib #CPP_SRCS = \ # ./src/testlib.cpp OBJS += \ ./lib/testlib.o-sim CPP_DEPS += \ ./lib/testlib.d -sim USER_OBJS := LIBS := # Each subdirectory must supply rules for building sources it contributes $(ODIR)/%.o-sim: $(SDIR)/%.cpp @echo 'Building file: $<' @echo 'Invoking: Cygwin C++ Compiler' $(CLANG) -c $(CLANGFLAGS_SIM) -arch $(ARCH_SIM) -isysroot $(SDKROOT_SIM) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o-sim=%.d-sim)" -I$(IDIR) -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' # All Target all: libtestlib-sim.a # Tool invocations libtestlib-sim.a: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: GCC Archiver' $(LIBTOOL) -static -arch_only $(ARCH_SIM) -syslibroot $(SDKROOT_SIM) -o libtestlib-sim.a $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' # Other Targets clean: -$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(ARCHIVES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libtestlib-sim.a -@echo ' '
makefile.cygwin 파일(참고용)
RM := rm -rf IDIR=./inc CC=g++ CFLAGS=-I$(IDIR) SDIR=./src ODIR=./lib #CPP_SRCS = \ # ./src/testlib.cpp OBJS += \ ./lib/testlib.o CPP_DEPS += \ ./lib/testlib.d USER_OBJS := LIBS := # Each subdirectory must supply rules for building sources it contributes $(ODIR)/%.o: $(SDIR)/%.cpp @echo 'Building file: $<' @echo 'Invoking: Cygwin C++ Compiler' $(CC) $(CFLAGS) -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' # All Target all: libtestlib.a # Tool invocations libtestlib.a: $(OBJS) $(USER_OBJS) @echo 'Building target: $@' @echo 'Invoking: GCC Archiver' ar -r "libtestlib.a" $(OBJS) $(USER_OBJS) $(LIBS) @echo 'Finished building target: $@' @echo ' ' # Other Targets clean: -$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(ARCHIVES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libtestlib.a -@echo ' '
정적라이브러리 만들기
빌드옵션
Header Search Paths 추가
Build Phase -> Link Binary With Libraries 추가
정적 라이브러리 메소드 호출
#include "testlib.h" 추가
실행
버튼 선택
- end -
ios - xcode 초간단 예제
안드로이드 - 정적 라이브러리 NDK 빌드
이전 글에서 만든 정적 라이브러리를 이용해서 안드로이드 ndk 컴파일,
안드로이드에서 실행해보는 것을 정리보았습니다.
testlibjni.h
#include <jni.h> #ifndef _Included_com_example_testlib_TestLib #define _Included_com_example_testlib_TestLib #ifdef __cplusplus extern "C" { #endif JNIEXPORT jstring JNICALL Java_com_example_testlib_TestLib_get_1version(JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif
testlibjni.cpp
#include "testlib.h" #include <jni.h> #include "testlibjni.h" JNIEXPORT jstring JNICALL Java_com_example_testlib_TestLib_get_1version(JNIEnv *env, jobject jobj) { return env->NewStringUTF(get_version()); }
Android.mk
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := testlib LOCAL_SRC_FILES := ../../testlib/src/testlib.cpp LOCAL_C_INCLUDES := \ /cygdrive/c/Android/workspaceCDT/testlib/inc \ $(call include-path-for, graphics corecg) include $(BUILD_STATIC_LIBRARY) # JNI include $(CLEAR_VARS) LOCAL_MODULE := testlibjni LOCAL_SRC_FILES := testlibjni.cpp LOCAL_STATIC_LIBRARIES := testlib LOCAL_C_INCLUDES := \ /cygdrive/c/Android/workspaceCDT/testlib/inc \ $(call include-path-for, graphics corecg) include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL := stlport_static STLPORT_FORCE_REBUILD := true
ndk-build
안드로이드 프로젝트 생성
TestLib.java
package com.example.testlib; public class TestLib { static { System.loadLibrary("testlibjni"); } public native static String get_version(); }
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:padding="@dimen/padding_medium" android:text="@string/hello_world" tools:context=".MainActivity" android:id="@+id/edtTitle" /> </RelativeLayout>
MainActivity.java
package com.example.testlib_android; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; import com.example.testlib.TestLib; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView edtTitle = (TextView) findViewById(R.id.edtTitle); edtTitle.setText(TestLib.get_version()); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
실행결과
Eclipst CDT - 정적(Static) 라이브러리 만들기
출처
http://erato1004.tistory.com/entry/eclipse에서-static-library를-만들고-링크하여-컴파일-하기
정적(Static) 라이브러리 만들기
1. 메뉴[New] -> [C++ Project] 선택
[Project name] : testlib [입력]
[Project type] : Static Library -> Empty Project [선택]
[Toolchains] : Cygwin GCC [선택]
버튼 [Finish] 선택
프로젝트 선택 -> [New] -> [Folder] 선택
[Folder Name] : inc [입력]
버튼 [Finish] 선택
아래 그림과 같이 폴더 구조와 파일을 생성
testlib.h
/* * testlib.h * * Created on: 2012. 9. 6. * Author: bluexmas */ #ifndef LIBTEST_H_ #define LIBTEST_H_ extern const char* get_version(); #endif /* LIBTEST_H_ */
testlib.cpp
/* * testlib.cpp * * Created on: 2012. 9. 6. * Author: bluexmas */ #include "testlib.h" const char* get_version() { return "testlib ver 0.1"; }
inclue 폴더 설정
프로젝트 선택 -> [Properties] 선택
[C/C++ Build] -> [Settings] -> [Cygwin C++ Compiler] -> [Includes] - 버튼 [Add] 선택
버튼 [Workspace...] 선택
[testlib] -> [inc] 폴더 선택
버튼 [OK] 선택
추가된 Include 폴더 확인
키 [Ctrl] + [B] 선택하여 컴파일하고, [Debug] 폴더 밑에 libtestlib.a 확인
정적 라이브러리 사용하기
1. 메뉴[New] -> [C++ Project] 선택
[Project name] : testlib_sample [입력]
[Project type] : Executable -> Empty Project [선택]
[Toolchains] : Cygwin GCC [선택]
버튼 [Finish] 선택
testlib_sample.cpp 파일
#include#include "testlib.h" int main(int argc, char **argv) { fprintf(stdout, "%s", get_version()); return 0; }
inclue 폴더 설정
Libraries 추가
Library search path 추가
키 [Ctrl] + [B] 선택하여 컴파일
실행해서 확인하기
실행결과
player
gplayer.xml
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- <SurfaceView android:id="@+id/gplayer_surfaceview" android:layout_height="fill_parent" android:layout_width="fill_parent"> </SurfaceView> --> <com.grubin.main.GrubinVideoView android:id="@+id/gplayer_surfaceview" android:layout_width="fill_parent" android:layout_height="fill_parent" > </com.grubin.main.GrubinVideoView> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top" android:orientation="vertical" > <ImageButton xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/btnBack" style="@style/MediaButton.Back" android:layout_gravity="right" android:layout_margin="20dip" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" /> <LinearLayout android:id="@+id/layoutController" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" /> </LinearLayout> </FrameLayout>
VideoController.java
package com.grubin.main; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageButton; import android.widget.LinearLayout; public class VideoController extends MediaController2 { private Button searchButton; private ImageButton mPushButton; private View.OnClickListener mPushListener; Context _context; private int screenWidth; private int screenHeight; public VideoController(Context context, boolean useFastForward, LinearLayout layout) { super(context, useFastForward, layout); _context = context; } public VideoController(Context context, AttributeSet attrs) { super(context, attrs); _context = context; } public VideoController(Context context, LinearLayout layout) { super(context, layout); _context = context; } public void setScreenSize(int screenWidth, int screenHeight) { this.screenWidth = screenWidth; this.screenHeight = screenHeight; } @Override public void setAnchorView(View view) { super.setAnchorView(view); LinearLayout L1 = (LinearLayout) getChildAt(0); for (int i = 0; i < L1.getChildCount(); i++) { View v = L1.getChildAt(i); if (v instanceof LinearLayout) { LinearLayout buttons = (LinearLayout) v; buttons.addView(makePushButton(L1)); break; } } /** * 0 : 컨트롤러 전체 * 1 : 컨트롤 버튼 * 2 : 탐색 바 */ //this.getc /* LinearLayout layout = (LinearLayout) getChildAt(0); // LinearLayout button = (LinearLayout)layout.getChildAt(1); // LinearLayout seek = (LinearLayout)layout.getChildAt(2); //view.getParent() LayoutInflater inf = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout linear = (LinearLayout) inf.inflate(R.layout.gplayer_controller, null); layout.addView(linear, 0); */ } /* @Override public void hide() { } */ /** * Super ugly hack */ public void extend() { LinearLayout L1 = (LinearLayout) getChildAt(0); for (int i = 0; i < L1.getChildCount(); i++) { View v = L1.getChildAt(i); if (v instanceof LinearLayout) { LinearLayout buttons = (LinearLayout) v; buttons.addView(makePushButton(L1)); break; } } } protected View makePushButton(ViewGroup parent) { LayoutInflater inflate = (LayoutInflater) LayoutInflater.from(_context); mPushButton = (ImageButton) inflate.inflate(R.layout.push_button, parent, false); if (mPushListener != null) mPushButton.setOnClickListener(mPushListener); return mPushButton; } public void setPushListener(View.OnClickListener push) { mPushListener = push; if (mPushButton != null) { mPushButton.setOnClickListener(mPushListener); } } }
MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.gplayer); // getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // surfaceView = (GrubinVideoView) findViewById(R.id.gplayer_surfaceview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnInfoListener(this); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnSeekCompleteListener(this); mediaPlayer.setOnVideoSizeChangedListener(this); btnBack = (ImageButton) findViewById(R.id.btnBack); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GPlayer.this.finish(); } }); mediaController = (new VideoController(this, (LinearLayout)findViewById(R.id.layoutController)) { @Override public void hide() { btnBack.setVisibility(View.INVISIBLE); super.hide(); } }); mediaController.setPushListener(new View.OnClickListener() { public void onClick(View v) { GPlayer.this.finish(); } }); Intent intent = getIntent(); playURI = intent.getStringExtra("url"); try { mediaPlayer.setDataSource(playURI); } catch (IllegalArgumentException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (IllegalStateException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (IOException e) { Log.v(LOGTAG, e.getMessage()); finish(); } currentDisplay = getWindowManager().getDefaultDisplay(); // mediaController.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { GPlayer.this.finish(); } }); } @Override public boolean onTouchEvent(MotionEvent ev) { Log.i("xxx", "onTouchEvent=" + ev.getAction()); if(ev.getAction() == MotionEvent.ACTION_DOWN) { /* Toast.makeText(this, "ev.getX()="+ev.getX() + "/" + btnBack.getLeft(), Toast.LENGTH_SHORT).show(); */ /* Toast.makeText(this, "btnBack.isShown()="+btnBack.isShown(), Toast.LENGTH_SHORT).show(); if (btnBack.isShown()) { // if (btnBack.getVisibility() == View.VISIBLE) { btnBack.setVisibility(View.INVISIBLE); } else { btnBack.setVisibility(View.VISIBLE); } */ if (mediaController.isShowing()) { mediaController.hide(); Log.v(LOGTAG, "mediaController.hide()"); } else { try { btnBack.setVisibility(View.VISIBLE); mediaController.show(10000); } catch (Exception e) { Log.e(LOGTAG,e.toString(),e); } Log.v(LOGTAG, "mediaController.show()"); } } return false; }