KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SourceEncoding


1 import au.id.jericho.lib.html.*;
2 import java.util.*;
3 import java.io.*;
4 import java.net.*;
5
6 public class SourceEncoding {
7     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
8         String JavaDoc sourceUrlString="http://freshmeat.net/projects/jerichohtml/";
9         if (args.length==0)
10           System.err.println("Using default argument of \""+sourceUrlString+'"');
11         else
12             sourceUrlString=args[0];
13         if (sourceUrlString.indexOf(':')==-1) sourceUrlString="file:"+sourceUrlString;
14         Source source=new Source(new URL(sourceUrlString));
15         source.setLogWriter(new OutputStreamWriter(System.err)); // send log messages to stderr
16
System.out.println("Original Source Encoding:");
17         System.out.println(source.getEncoding());
18         System.out.println("Specified by:");
19         System.out.println(source.getEncodingSpecificationInfo());
20     }
21 }
22
Popular Tags