title: Maximum input length exceeded of java program in linux shell
body: <p>I've created a wonderfully working program that encrypts the text a person enters with a keyword of their choice. The program can decrypt the encrypted message/text by going in decrypt mode and entering the correct key.<br>
  Now my problem is that when I enter a text in the Linux shell that's longer than approximately 5000 characters, it doesn't process all the text. I used <a href="https://germantestdrive.wordpress.com/2009/07/09/langer-test-text/" rel="nofollow noreferrer">this</a> German dummy text that's 15954 characters long. If I enter the text in the Linux shell It cuts off my text at about 4025 characters. On the other hand, if I execute the program in IntelliJ everything works like a charm. If you need the code I got on git <a href="https://github.com/LJJW/Vigenere-Cipher.git" rel="nofollow noreferrer">here</a>.<br>
  Thanks in advance. I appreciate the help.</p>
  
  <p>My Start class that starts everything</p>
  
  <pre><code>public class Start
  {
      public static void main(String[] args)
      {
          Scanner scanner = new Scanner(System.in);
          System.out.print("Would you like to encrypt or decrypt a message? [d/e]\n&gt;");
          char de = scanner.nextLine().charAt(0);
          boolean _Encrypt = true;
  
          if (de == 'd')
              _Encrypt = false;
          else if (de == 'e')
              ;
          else
          {
              System.out.println("Non valid input. Please try again later.");
              System.exit(1);
          }
  
          char[] text = ch.wagner.root.viginere.Input.getText("Text:\n&gt;");
  
          char[] key = ch.wagner.root.viginere.Input.getKey("Key:\n&gt;");
  
          if (_Encrypt)
          {
              System.out.println(ch.wagner.root.viginere.Process.encrypt(text, key));
          }
          else
          {
              System.out.println(ch.wagner.root.viginere.Process.decrypt(text, key));
          }
      }
  }
  </code></pre>
  
  <p>My Input class</p>
  
  <pre><code>public class Input
  {
      public static char[] getText (String requestMessage)
      {
          boolean _AllowedToContinue = false;
  
          char[] text = null;
          while (!_AllowedToContinue)
          {
              System.out.print(requestMessage);
              text = ch.wagner.root.viginere.Input.getCharArray();
  
              if (!Input.inputValid(new String(text), "[^`^]+$"))
                  System.out.println("Invalid input. Try again.");
              else
                  _AllowedToContinue = true;
          }
  
  //      System.err.println(new String(text).length());
  //      Created this to check the length of the String after input
  
          return text;
      }
  
      public static char[] getKey (String requestMessage)
      {
          boolean _AllowedToContinue = false;
  
          char[] key = null;
          while (!_AllowedToContinue)
          {
              System.out.print(requestMessage);
              key = ch.wagner.root.viginere.Input.getCharArray();
  
              if (!Input.inputValid(new String(key), "^[A-Za-z]+$"))
                  System.out.println("Invalid input. Try again.");
              else
                  _AllowedToContinue = true;
          }
  
          return key;
      }
  
      private static boolean inputValid (String input, String regex)
      {
          boolean returnValue = true;
  
          final Pattern pattern = Pattern.compile(regex);
          if (!pattern.matcher(input).matches()) {
              returnValue = false;
          }
  
          return  returnValue;
      }
  
      private static String getString ()
      {
          Scanner scanner = new Scanner(System.in);
  
          return scanner.nextLine();
      }
  
      private static char[] getCharArray ()
      {
          return getString().toCharArray();
      }
  }
  </code></pre>
  
  <p>The Process class that encrypts/decrypts the text</p>
  
  <pre><code>public class Process
  {
      public static String decrypt(char[] text, char[] key)
      {
          int[] shift = new int[key.length];
  
          key = new String(key).toUpperCase().toCharArray();
  
          for (int i = 0; i &lt; shift.length; i++)
              shift[i] = key[i] - 65;
  
          int ii = 0;
          for (int i = 0; i &lt; text.length; i++)
          {
              if (ii == shift.length)
                  ii = 0;
  
              if (Character.isLetter(text[i]))
              {
                  if (((((text[i] - 65) - shift[ii]) % 26) + 65) &lt; 65)
                      text[i] = (char) (((((text[i] - 65) - shift[ii]) % 26) + 65) + 26);
                  else
                      text[i] = (char) ((((text[i] - 65) - shift[ii]) % 26) + 65);
              }
              ii++;
          }
  
          return new String(text);
      }
  
      public static String encrypt(char[] text, char[] key)
      {
          int[] shift = new int[key.length];
  
          key = new String(key).toUpperCase().toCharArray();
  
          for (int i = 0; i &lt; shift.length; i++)
          {
              shift[i] = key[i] - 65;
          }
  
          text = new String(text).replaceAll("[^a-zA-Z0-9|/()*]+", "").toCharArray();
  
          int ii = 0;
          for (int i = 0; i &lt; text.length; i++)
          {
              if (ii == shift.length)
                  ii = 0;
  
              text[i] = Character.toUpperCase(text[i]);
  
              if (Character.isLetter(text[i]))
                  text[i] = (char)((((text[i] - 65) + shift[ii]) % 26) + 65);
              ii++;
          }
  
          return new String(text);
      }
  }
  </code></pre>
  
  <p></p>