2013-06-10 1 views
-2

키 값 구분 기호로 || 인 ini 파일이 있습니다. ini4j 라이브러리를 사용하여 구문 분석하고 싶지만 코드를 실행할 때마다 오류 (예외)가 발생합니다. ini4j는 키 - 값 구분 기호로 =: 만 식별한다고 생각합니다. ini4j를 사용하는 동안 파일을 구문 분석 할 수있는 다른 방법이 있습니까?ini 파일의 키 값 구분 기호 변경

이 내 예

[header] 
one||1 
two||2 

[section1] 
three||3 
four||4 
five||5 
six||6 

[section2] 
seven||7 
eight||8 
nine||9 

파일입니다이 내 예제 코드

public static void main(String[] args) throws IOException { 
    Ini ini=new Ini(new File("/home/esunmes/NetBeansProjects/ini4jexample/src/ini4jexample/newfile2.ini")); 
    for(String str:ini.keySet()) 
    {System.out.println(str); 
    Ini.Section section=ini.get(str); 
    for(String key:section.keySet()) 
    {System.out.println("the key is : "+key);// TODO code application logic here 
} 

} 나는 또한 사건을 알고 싶어

입니다 : 키 || 값 1 || 값 2

+3

찾기 및 바꾸기? –

+0

예외는 무엇이라고 말합니까? 스택 추적을 게시 할 수 있습니까? –

+0

만약 내가 큰 번호를 주기적으로하고 싶다면? 로그? – user2470087

답변

1

delimeter를 예상 =으로 바꾸는 것은 어떻습니까?

String inputPropties = "KEY1||VALUE1\nKEY2||VALUE2\nKEY3||VALUE3"; 
    inputPropties = inputPropties.replaceAll("\\|\\|","="); 
    Properties properties = new Properties(); 
    properties.load(new StringReader(inputPropties)); 
    for(String key: properties.stringPropertyNames()) { 
     System.out.println(key+" = "+properties.getProperty(key)); 
    }