title: how to merge this two method together using functional programming in java
body: <p>I need to merge these two method together using functional programming, but I am not familiar with it, is there anyway to do it?</p>
  
  <pre><code>private String getCsvHeader(Object obj) {
      Field[] fields = obj.getClass().getFields();
      StringBuilder sb = new StringBuilder();
      String prefix = "";
  
      for (Field field : fields) {
          sb.append(prefix).append(field.getName());
          prefix = ",";
      }
      return sb.toString();
  }
  
  private String getCsvString(Object obj) throws IllegalAccessException {
  
      Field[] fields = obj.getClass().getFields();
      StringBuilder sb = new StringBuilder();
  
      String prefix = "";
      for (Field field : fields) {
          sb.append(prefix).append(field.get(obj));
          prefix = ",";
      }
      return sb.toString();
  }
  </code></pre>