2017-12-22 47 views
1

내가 쓴 나에게 다음과 같은 출력 준 다음 코드 :스크립트는 몇 가지 더있는 경우가없는 코드를 실행하지 않습니다 - 절 또는 유사한

if(bodytoUpper.contains(currentfield)){ 
    int index = bodytoUpper.lastIndexOf(currentfield + "\n")//finds the last appearance of the field value 
    log.debug("Index try if Abfrage: ") 
    log.debug(index) 
    int nextindex = bodytoUpper.lastIndexOf(nextfield, index)//finds the index of the next field 
    log.debug("nextindex: ") 
    log.debug(nextindex) 
    value = currentbody.substring(index+currentfield.length(), nextindex);//sets the value to everything between the two indexes 
    log.debug("Rückgabewert: ") 
    log.debug(value) 
} 

그 부분의 출력은 다음 로그입니다 :

2017-12-22 11:24:52,853 DEBUG [acme.CreateSubtask]: Index try if Abfrage: 
2017-12-22 11:24:52,853 DEBUG [acme.CreateSubtask]: 18 

일부 로그가 누락되어 있으며 코드도 실행되지 않지만 오류 메시지가 출력되지 않는 문제가 있습니다.

+1

'nextfield'의 값은 무엇입니까? 로그에 예외가 있습니까? (/ 예외를 삼키고 있습니까?) –

+0

Nextfield는이 경우 문자열 "STATUS"입니다. 나는 그것이 정말로 그것이라고 테스트했다. 로그에 예외가 없습니다. nextfield를 "STATUS"로 바꾸는 것도 도움이되지 못했습니다. –

답변

0

스크립트의 목표는 모르겠지만 마지막 두 가지 모양 사이의 모든 내용을 인쇄하는 것입니다.

나는 문제가 당신이 거꾸로 찾고 있다고 생각한다. 그래서 nextindex는 BFORE index이다. 따라서 코드를 다음과 같이 수정해야합니다 :

value = currentbody.substring(nextindex+currentfield.length(), index); 
+0

왜 전에 로그를 기록하지 않습니까? 'log.debug ("nextindex :")' –

+0

아무 생각도 없지만 일부 디버깅이 도움이 될 것입니다. 우리는 입력을 모르지만. – GregT