내 문제 : 텍스트 파일에서 여러 값을 가져와야합니다.
ttcn-3 언어에서 XML 언어로의 파서 작업 중이며 XML 파일을 작성하기 위해 텍스트 파일에 작성된 ttcn 모듈에서 몇 가지 핵심 단어와 값을 가져 오는 것입니다.
내 ttcn 코드의 시작은 다음과 같습니다 .
module SessionSetup
{
type port InputPortType message { in charstring }
type port OutputPortType message { out charstring }
type component SessionSetupResComponentType {
port InputPortType InputPort;
port OutputPortType OutputPort;
}
예를 들어 모듈 (SessionSetup) 바로 뒤에있는 문자열을 가져와야하며 여기에 내가 만든 코드가 있습니다.
public void ReadTheFileGetTheModuleName(String fichier){
try{
InputStream ips=new FileInputStream(fichier);
InputStreamReader ipsr=new InputStreamReader(ips);
BufferedReader br=new BufferedReader(ipsr);
String ligne;
while ((ligne=br.readLine())!=null){
if (ligne.contains("module"))
{
String[] st = ligne.split(ligne, ' ');
System.out.println("Nom = "+st[1]);
}
chaine+=ligne+"\n";
}
br.close();
}
catch (Exception e){
System.out.println(e.toString());
}
}
문제는 작동하지 않고 모듈 이후에 문자열을 얻지 못한다는 것입니다.
감사
String[] st = ligne.split(ligne, ' ');
/\/\/\/\/\/\/\
Incorrect way, pass some regex on which string should split
귀하의 String#Split()
방법이 잘못되었습니다. 문서를 확인하십시오.
이럴거야
public String[] split(String regex, int limit)
or
public String[] split(String regex)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다