title: How can I enter a new line at Netbeans' run section?
body: <p>I have written a code which transforms all the new line characters to comma. If a character is <code>'\n'</code> it will change it to <code>','</code>. But I am having problems entering my sample data. I think Netbeans takes spaces as new line characters. Pressing enter at the run section inputs the data I have written instead of creating a new line. What should I do ?</p>
  
  <p>I am also open to suggestions about my code.</p>
  
  <p>This is the code:</p>
  
  <pre><code>package newlinetocomma;
  
  import java.util.Scanner;
  
  /**
  *
  * @author sametsahin
  */
  public class NewLineToComma {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
  
      Scanner scanner = new Scanner(System.in);
  
      System.out.println("Enter a text: ");
      String textWithNewLines = scanner.next();
  
      char[] textWithNewLinesAsArray = textWithNewLines.toCharArray();
  
      for (int i = 0; i &lt; textWithNewLinesAsArray.length; i++) {
  
          if (textWithNewLinesAsArray[i] == '\n') {
  
              textWithNewLinesAsArray[i] = ',';
  
          }
  
      }
  
      for (int i = 0; i &lt; textWithNewLinesAsArray.length; i++) {
  
          System.out.print(textWithNewLinesAsArray[i]);
  
      }
  
    }
  
  }
  </code></pre>