I’m new to using Java, but I have some previous experience with C#. The issue I’m having comes with reading user input from console. I’m running into the “java.util.NoSuchElementException” error with this portion of code: I have two functions that get user input: PromptCustomerQt…
Tag: java
Exclude individual test from ‘before’ method in JUnit
All tests in my test class execute a ‘before’ method (annotated with JUnit’s @Before) before the execution of each test. I need a particular test not to execute this before method. Is there a way to do it? Answer Unfortunately you have to code this logic. JUnit does not have such feature. Ge…
Posting image to wcf rest service from Android
I’m having a problem to post a image to my wcf rest service. I’m posting some parameters of which one of them is a base64 utf-8 encoded string (the image). My problem is that every time I post I get “bad request”. Here is the code It is something with the encoded string, but what? Answ…
A shortcut to select a line in Eclipse?
Is there a keyboard shortcut to select all the line your cursor is currently on? In Eclipse? Or even in general on Windows/Linux? Answer Solution for Eclipse: Hold Alt and press ↑ and ↓. Alt + ↑ and ↓ will move an entire line up or down, so just move it back and you end up with the entire line
Why does p:panelGrid not work with ui:repeat?
If I use as below, I get no error, no output. Why does p:panelGrid not work with ui:repeat? Note : I don’t want to use c:forEach because of the I already face a lot of JSF issue. MyBean.java Expected output with primefaces Answer ui:repeat will not work because it does not actually add components to the…
Making Spring 3 MVC controller method Transactional
I am using Spring 3.1 and have my DAO and service layer(transactional) written. However in a special case to avoid a lazy init exception I have to make a spring mvc request handler method @transactional. But It is failing to attach transaction to that method. Method name is ModelAndView home(HttpServletReques…
How to multiply a BigDecimal by an integer in Java
How do you multiply a BigDecimal by an integer in Java? I tried this but its not correct. Answer You have a lot of type-mismatches in your code such as trying to put an int value where BigDecimal is required. The corrected version of your code:
How to handle an Alert with “UnexpectedAlertBehaviour” capability in Selenium?
In selenium framework 2.25, I see that we have the UnexpectedAlertBehaviour enum type, but I don’t know how to use it. Answer I found this portion of documentation on your issue: This may be useful for other people as well: v2.25.0 ======= WebDriver: Added API for dealing with BASIC and DIGEST authentic…
Thread interruptions are not caught by InterruptedException
I have a controller and a thread that does some work, the controller has an interrupt function that shuts off the threads in emergency situation. the skeleton of my code looks something like this: However, when interrupt is called, the InterruptedException is never caught. What am I doing wrong here? Answer T…
C# and Java DES Encryption value are not identical
I am trying to encrypt the same data using C# and Java. If the data is more than 7 bytes then Java and C#’s encrypted value are not identical. Input 1: a java output: FrOzOp/2Io8= C# output: FrOzOp/2Io8= Input 2: abc j : H9A/ahl8K7I= c#: H9A/ahl8K7I= Input 3: aaaaaaaa (Problem) j : Gxl7e0aWPd7j6l7uIEuMx…