2 methods to parse the same pattern of line in a file I use 2 methods in order to parse those 2 lines:

flux=rp_evtmedprev_out
partitions=a054010a,a054020a,a054030a,a034040a,a054050a,a054060a,a054070a,a054080a,a054090a


This is the call:

BufferedReader reader = new BufferedReader(new InputStreamReader(
        httpConn.getInputStream()));
StringBuilder buf = new StringBuilder();
String line = null;

String flux = reader.readLine();
String partitionsString = reader.readLine();
insertToplogieNatures(flux, topologie);
insertToplogiePartitions(partitionsString, topologie);


Is there a way to merge those 2 methods:

public void insertToplogiePartitions(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = line.split("=");
    splitLigneDeuxiemePartie = splitLigneDeuxiemePartie[1].split(",");
    Partition partTemp;
    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();

    for (String partStringTemp : splitLigneDeuxiemePartie) {
        partTemp = new Partition();
        partTemp.setHostname(partStringTemp);
        partitionsBuild.add(partTemp);
    }
    topologie.setPartitions(partitionsBuild);
}

public void insertToplogieNatures(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = line.split("=");
    splitLigneDeuxiemePartie = splitLigneDeuxiemePartie[1].split(",");

    List&lt;String&gt; naturesBuild = new ArrayList&lt;String&gt;();

    for (String natureTemp : splitLigneDeuxiemePartie) {
        naturesBuild.add(natureTemp);
    }
    topologie.setNatures(naturesBuild);
}


If it's possible, I'm not even sure that it would be a good idea due to readability.
The first part could be merged, for sure.

public void insertToplogiePartitions(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = line.split("=");
    splitLigneDeuxiemePartie = splitLigneDeuxiemePartie[1].split(",");


Wrap it in a method

public String[] extractSplitLigneDeuxiemePartieFromLine(String line){
    String[] splitLigneDeuxiemePartie = line.split("=");
    return splitLigneDeuxiemePartie[1].split(",");
}


and use it like so:

public void insertToplogiePartitions(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = extractSplitLigneDeuxiemePartieFromLine(line);
    Partition partTemp;
    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();

    for (String partStringTemp : splitLigneDeuxiemePartie) {
        partTemp = new Partition();
        partTemp.setHostname(partStringTemp);
        partitionsBuild.add(partTemp);
    }
    topologie.setPartitions(partitionsBuild);
}

public void insertToplogieNatures(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = extractSplitLigneDeuxiemePartieFromLine(line);
    List&lt;String&gt; naturesBuild = new ArrayList&lt;String&gt;();

    for (String natureTemp : splitLigneDeuxiemePartie) {
        naturesBuild.add(natureTemp);
    }
    topologie.setNatures(naturesBuild);
}


For the rest, it's better to take a separate approach because these functions do different things.

Try Arrays.asList for the natures.

public void insertToplogieNatures(String line, Topologie topologie) {
    topologie.setNatures(
        Arrays.asList(extractSplitLigneDeuxiemePartieFromLine(line))
    );
}


For the partitions, you could perhaps simplify by making a new constructor for Partition that takes hostName as parameter:

public void insertToplogiePartitions(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = extractSplitLigneDeuxiemePartieFromLine(line);
    Partition partTemp;
    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();

    for (String partStringTemp : splitLigneDeuxiemePartie) {
        partTemp = new Partition(partStringTemp);
        partitionsBuild.add(partTemp);
    }
    topologie.setPartitions(partitionsBuild);
}


Allowing you to remove storing to temporary local variable:

public void insertToplogiePartitions(String line, Topologie topologie) {
    String[] splitLigneDeuxiemePartie = extractSplitLigneDeuxiemePartieFromLine(line);

    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();
    for (String partStringTemp : splitLigneDeuxiemePartie) {
        partitionsBuild.add(new Partition(partStringTemp));
    }
    topologie.setPartitions(partitionsBuild);
}


But now that you have only a single use of splitLigneDeuxiemePartie, you don't need to store that in a local variable either:

public void insertToplogiePartitions(String line, Topologie topologie) {
    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();
    for (String partStringTemp : extractSplitLigneDeuxiemePartieFromLine(line)) {
        partitionsBuild.add(new Partition(partStringTemp));
    }
    topologie.setPartitions(partitionsBuild);
}


Sometimes local stores help with clarification, and sometimes they don't. In this case, you have french variable names which I don't understand, and the local variable names don't help me understand your code, so I prefer the shortened form.

...

Although, if we're going to use a constructor which takes a hostName, you might as well label your temporary variable as such.

public void insertToplogiePartitions(String line, Topologie topologie) {
    List&lt;Partition&gt; partitionsBuild = new ArrayList&lt;Partition&gt;();
    for (String hostName : extractSplitLigneDeuxiemePartieFromLine(line)) {
        partitionsBuild.add(new Partition(hostName));
    }
    topologie.setPartitions(partitionsBuild);
}