You close the second Scanner which closes the underlying InputStream, therefore the first Scanner can no longer read from the same InputStream and a NoSuchElementException results. The solution: For console apps, use a single Scanner to read from System.in. Aside: As stated...
  • April 8, 2022
  • 0 Comments
If you try to decrypt PKCS5-padded data with the wrong key, and then unpad it (which is done by the Cipher class automatically), you most likely will get the...
  • April 8, 2022
  • 0 Comments
While reading from the file, your are not terminating your loop. So its read all the values and correctly throws EOFException on the next iteration of the read at line below:...
  • April 8, 2022
  • 0 Comments