2017년 9월 5일 화요일

문자 자르기

nNext_Money = map.get("Next_Money").substring(0,14);
 
문자 자르기 앞에서 0 ~ 14 번째 까지 잘라 nNext_Money 에 전달. 
 

XML jsoup

JSoup은 간단히 외부 url에 접근해서, 문서를 가져올 수 있게끔 지원한다.
다음과 같은 코드를 이용해서 특정 url에 접근할 수 있다.
        Document doc = Jsoup.connect("http://openapi.naver.com/search")
                .data("key", API_KEY_NAVER_IMG_SEARCH)
                .data("query", URLEncoder.encode(keyword, "UTF-8"))
                .data("target""image").data("start""1")
                .data("diplay"String.valueOf(count)).userAgent("Mozila")
                .parser(Parser.xmlParser()).timeout(3000).get();

connect의 파라메터로, 접근할 URL을 작성하고 
data 메소드를 이용해서 HTTP 접근시 이용할 파라메터를 추가해줄 수 있다.
XML 파싱을 할때의 가장 주의할 점은, parser를 xml파서로 꼭 지정을 해주어야한다는 점이다.
parser 메소드의 명시적 선언없이, 그냥 사용을 하면, 문서구조는 잘 불러와지나, 
실제 필요한 데이터를 select하였을 시 빈 데이터값만 받아진다.
따라서, .parser를 xml파서로 등록을 해주고, 마지막에 HTTP METHOD에 맞는 함수를 호출하면 된다.
그 후 원하는 속성의 데이터를 불러오기 위해선, 
Elements라는 객체와, Element 객체를 이용해서 데이터를 불러오게 되는데,
다음의 코드를 이용해서 불러올 수 있다.
        Elements elements = doc.select("link");
        System.out.println("elements = " + elements);
        for (Element e : elements) {
            System.out.println(e.text());
        }
document 인스턴스에서, link라는 이름을 가진 노드를 가져와서 출력하는 코드이다.

select 메소드를 이용해서, 특정 문자열을 가진 노드를 가져올 수 있고,
노드 객체인 element의 text 메소드를 이용해서 실제 값을 받을 수 있다.

2017년 9월 4일 월요일

jsoup 으로 끌어온 파일 어레이 저장

winperson1 = document.select(".first .results .number");
  String[] pbnum = new String[winperson1.size()];
  for(int i=0;i  pbnum[i]=winperson1.get(i).text();
   }

jsoup to array use for loop
jsoup 으로 끌어온 파일 어레이 저장





java 문자 형 작업


웹에서 가저운 문자중 특수 문자들이 석여 있어 그것들을 잘라 버려야 하는데
아래와 같이  replaceall 구문을 사용하면 순쉽게 잘라낼수 있다.

[html 테그제거]
Wwinperson1 = winperson1.toString().replaceAll("\\<.*?>","");


[라인 브레이크 제거 후 - 로 대체]
Wwinperson1 = Wwinperson1.replace("\n"," - ");


도통 위와 같이 사용 합니다.

2017년 9월 3일 일요일

중국 쌍색구(双色球)

중국 쌍색구(双色球)

빨간공 6개 : 1~33
판란색 1개 : 1~16

빨간색, 파란색 두가지 색이라 쌍색구 라 함


APP LINK
https://play.google.com/store/apps/details?id=gotopark.buster.chinaLotgen


쌍색구 site
당첨번호 확인 가능
http://www.zhcw.com/ssq/

당첨번호 확인
http://www.zhcw.com/ssq/kjgg/zuixinkaijiang/



2017년 9월 2일 토요일

그레들 버젼 정보 가져오기

[gradle version 정보 가져오기]
String versionCode = BuildConfig.VERSION_NAME;

text1.setText("幸運のMiniLoto番号 発生機"+versionCode);


[string xml 에서 가져오기]
String versionCode = BuildConfig.VERSION_NAME;
String app_name = getString(R.string.app_name);

proguard 설정

-optimizationpasses 5

#When not preverifing in a case-insensitive filing system, such as Windows. Because this tool unpacks your processed jars, you should then use:
-dontusemixedcaseclassnames

#Specifies not to ignore non-public library classes. As of version 4.5, this is the default setting
-dontskipnonpubliclibraryclasses

#Preverification is irrelevant for the dex compiler and the Dalvik VM, so we can switch it off with the -dontpreverify option.
-dontpreverify

#Specifies to write out some more information during processing. If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message.
-verbose

#The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle. Note that the Dalvik VM also can't handle aggressive overloading (of static fields).
#To understand or change this check http://proguard.sourceforge.net/index.html#/manual/optimizations.html
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class org.jsoup.** {
  public *;
 }




gradle

    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


layout

tools:shrinkMode="strict">