title: Copy and write the identical content in a new file (Java)
body: <p>my goal is to copy the identical content of a file, replace some words and write the content in a new file.</p>
  <p>I don't understand the problem, it takes the content correctly except for the line breaks.
  It also recognizes multiple consecutive white spaces but does not take the new line.
  Here the code i wrote for it:</p>
  <pre><code>public class FileDefinition {
  
  String result = &quot;&quot;;
  
  String pathxml = pathxmlin;
  
  String pathconf = pathfileconf;
  
  //func to be recalled in the main for the different files
  public String getPropValues() throws IOException {
      try {
          Properties prop = new Properties();         
          String pathconf = this.pathconf;
          String pathxml = this.pathxml;
          
          //Read file conf
          File inputFile = new File(pathconf);
          InputStream is = new FileInputStream(inputFile);
          BufferedReader br = new BufferedReader(new InputStreamReader(is));
  
          //load the buffered file
          prop.load(br);
  
  
          // get the property value and print it out
          String name = prop.getProperty(&quot;name&quot;);
          String loc = prop.getProperty(&quot;location&quot;);
          String id = prop.getProperty(&quot;PropID&quot;);
          
          //Read scxml file to get the format
          FileReader reader = new FileReader(pathxml);
              
          //research fields to be changed
          String searchname = &quot;RotaionToInside&quot;;
          String searchlocation = &quot;location&quot;;
          String searchpropid = &quot;PropOfJobID&quot;;
              
          String newString;
          StringBuffer str = new StringBuffer();;
      
          BufferedReader rb = new BufferedReader(reader);
          while ((newString = rb.readLine()) != null){
          str.append(newString.replaceAll(searchlocation, loc));
          str.append(newString.replaceAll(searchpropid, id));
          str.append(newString.replaceAll(searchname, name));             
          }
  
          rb.close();
          
          String pathwriter = pathxml + name + &quot;.scxml&quot;;
          
          BufferedWriter bw = new BufferedWriter(new FileWriter(new File(pathscxmlout)));
          bw.write(str.toString());        
          //flush the stream
          bw.flush();      
          //close the stream
          bw.close();
              
      } catch (Exception e) {
          System.out.println(&quot;Exception: &quot; + e);
      }     
      
      return result;
  }   
  }
  </code></pre>