Use the page here , you just click on points and the distance will appear either in miles or in kilometers. You can also mark multiple points and calculate a real length of a path.
HTML and XML escape format is widely used in web and XML transactions. There is a great utility for this purpose in Java world : Lang package in apache commons project Download commons-lang and put the commons-lang-xxx.jar file in your classpath or in your project. The StringEscapeUtils class is your key class here. Use static escapeXml() , escapeHtml() , unescapeXml() , unescapeHtml() methods. String escaped = StringEscapeUtils.escapeXml(" "); Great & Lifesaving , thanks apache again !
Here is a sample code I just wrote. This class copies one file to another. By understanding this code below , you will comphrend both reading from and writing to file concepts in java. I used FileInputStream and FileOutputStream in this code. package javacream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class FileUtil { public static void copyFile(String strInputFileName , String strOutputFileName) throws IOException { //Prepare file objects File fInputFile = new File(strInputFileName); File fOutputFile = new File(strOutputFileName); //Prepare read write streams from file objects FileInputStream fis = new FileInputStream(fInputFile); FileOutputStream fos = new FileOutputStream(fOutputFile); int c; // read from the input file and write to the output file while ((c = fis.read()) != -1) { ...
Sort based on keys is simple , just dump the map into TreeMap (TreeMap is sorted by nature) Map myMap = new HashMap(); // put keys and values... ..... Map sortedMap = new TreeMap(myMap); If you want to sort your HashMap based on values : HashMap map1 = new HashMap(); map1.put("cat",5); map1.put("cow",4); map1.put("dog",3); map1.put("horse",2); List mpKeys = new ArrayList(map1.keySet()); List mpValues = new ArrayList(map1.values()); HashMap map = new LinkedHashMap(); TreeSet sortedSet = new TreeSet(mapValues); Object[] sortedArray = sortedSet.toArray(); int size = sortedArray.length; // descending for (int i=size-1; i>=0; i--) System.out.println(mpKeys.get(mpValues.indexOf(sortedArray[i]))+" "+sortedArray[i]); Any discussions will be appreciated.