public static void openFile(File fileObj)
{
    StringBuilder sb = new StringBuilder();
    sb.append("cmd.exe /C start ");
    sb.append(fileObj.getAbsolutePath());
    System.out.println("openFile: " + sb);
    try
    {
        Runtime.getRuntime().exec(sb.toString());
    }
    catch (IOException e)
    {
        System.out.println("EEExxxccc");
    }
    }
Friday, August 26, 2011
Open file with default program
In my example I have pdf file that I want to be opened as soon as it is saved to disk.
Tuesday, August 23, 2011
Hibernate -distinct (with disjunction) via criteria
How to write distinct using Hibernate criteria API?
DetachedCriteria crit = DetachedCriteria.forClass(clazz);
Disjunction dis = Restrictions.disjunction(); // OR
dis.add(Restrictions.eq("billType", BillType.RACUN));
dis.add(Restrictions.eq("billType", BillType.STORNO));
crit.add(dis);
crit.setProjection(Projections.distinct(Projections.property("billSubtype")));
Criteria criteria = crit.getExecutableCriteria(getSession());
return crit.list();
select distinct B.BILLSUBTYPE from bill b where (B.BILLTYPE = 'RACUN' or B.BILLTYPE = 'STORNO')
http://www.jairrillo.com/blog/2009/01/29/how-to-use-left-join-in-hibernate-criteria/
Subscribe to:
Posts (Atom)