Archive for February, 2008

How to validate XML using XSD ?

February 29, 2008
By admin

ErrorChecker errors = new ErrorChecker(); try {         SAXParser parser = new SAXParser();    parser.setFeature(“http://xml.org/sax/features/validation“, true);    parser.setFeature(“http://apache.org/xml/features/validation/schema“, true);    parser.setFeature(“http://apache.org/xml/features/validation/schema-full-checking”,true);    parser.setProperty(“http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation”,xsdFile);    parser.setErrorHandler(errors);    parser.parse(inputSource);          } catch (Exception e) {    e.printStackTrace();  }
Read more »

Tags: , , ,
Posted in Core Java, J2EE | No Comments »

How get a filename without extensions ?

February 10, 2008
By admin

File f = new File(args); String fileName = f.getName().substring(0, f.getName().lastIndexOf(“.”)); System.out.println(“..” + fileName);
Read more »

Tags: , ,
Posted in Core Java, Faq, J2EE | No Comments »

How to use FilenameFilter?

February 10, 2008
By admin

import java.io.FilenameFilter; import java.io.File; class HTMLFilter implements FilenameFilter {                       public boolean accept(File dir, String name) {                                 return (name.endsWith(“.html”));                       }      } class Main {         public static void main (String args) {             String dir = “.”;            if (args.length == 1)             dir = args;              File f1 = new File(dir);...
Read more »

Tags: , , ,
Posted in Core Java, J2EE | No Comments »

Calendar

    February 2008
    M T W T F S S
    « Nov   Mar »
     123
    45678910
    11121314151617
    18192021222324
    2526272829