java

Print Consecutive Occurrences of Each Character in String Java

Posted on

Problem Statement: Write a program to print consecutive occurrences of each character in a given string.

Test case 1:
Input : affffssdaaag
Output: a1f4s2d1a3g1

Test case 2:
Input: affffssdaaa
Output: a1f4s2d1a3

Test case 3:
Input: aaa
Output: a3 Read the rest of this entry »

Count Occurrences of Character in a String Java

Posted on Updated on

Problem Statement: Write a program to count occurrence of each character in a given string.

Test case 1:
Input : aabacghc
Output: a3b1c2g1h1

Test case 2:
Input: aaabbcccc
Output: a3b2c4 Read the rest of this entry »

Secure Jersey 2 Hello World Example

Posted on Updated on

Jersey is very popular framework to build restful services. In this tutorial, we will learn how to do HTTP basic authentication, so that user won’t be able to access any resource untill they provided the correct username and passowrd. This example has been extended from our previous simple Jersy 2 Hello World tutorial. Please refer the previous tutorial for technology used and basic configurations.

Read the rest of this entry »

Read a file in java

Posted on Updated on

Java IO package contains classes which programmers are used to read content of a file . However, there are different ways to read content of a file and thus create dilemma to select one method over other. To select a efficient way, one should first consider nature of input file, content whether small or large and so on. In this blog, we have come up with different ways to read a file in Java with example. Read the rest of this entry »