Friday, 18 October 2013

How get current path in java system dir

many time we required to get current system dir path

String currentPath= System.getProperty("user.dir");











here is full example




public class Path {
                
            public static void main(String args[]) {
            
                String currentPath = System.getProperty("user.dir");
               System.out.println(" ");
                         System.out.println("Current working directory path in Java : " + currentPath);
            
            }
        }

java msql jdbc example

java msql jdbc example


create jar file from command prompt

create jar file from command prompt

 The fromat is :-

jar cf jarfile  .*
For Example :- jar cf test.jar .*

this will add all file and create test.jar


split by space in java

split by space in java

str.split("\\s+");

This will split by space.

how to create new line in html

how to create new line in html
Try this

<br>

Tag this will break line

Thursday, 17 October 2013

how to get map key in java

Try this

Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}

How to Iterate Through a HashMap

Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
    System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}