Posts

Showing posts from January, 2013

Git configure on ubuntu

To configure GIT server on your ubuntu machine, Please follow following steps: Configure GIT Server 1. Make sure git is installed on your ubuntu machine. We can insure about this by following command  > git --version it should display the GIT version. 2. We need to create user for GIT. Perform following steps to create user : > sudo adduser username it will ask for password, Enter your new password for GIT and enter the correct information. > su username >  mkdir projectFolder > cd projectFolder > mkdir project.git > cd project.git > git --bare init Now your empty repository has been created. You can push files to this repo. Push files to GIT Server We can push files to GIT server from remote machines. Perform following steps to push files from a linux machine. 1. Create a folder, in which you want to clone your git project. > mkdir myGitProject > cd  myGitProject 2. We will clone our git project here. > git clone user@g

Split string in Java

In java to split string, we use split function of String class. Example : We want to split string java:advanced:cpp based on : character. We will use it like this-               String value=  "java:advanced:cpp"               String[] resultArray = value.split(":")           Resultant array will have following values: "java","advanced","cpp" Split function takes input as regex expression. So if we want to split string based on some special character, then it will not be similar like we did before. Example:                    String value = "Java [ advanced [ cpp ";                    String[] resultArray = value.split("[");   this will throw a runtime exception PatternSyntaxException . We are trying to split the string based on "[" character, which is open square bracket for a regex expression. So it consider this as open bracket and it looks for closing bracket, So it throws the exception.