Obtaining Facelets templates/files from an external filesystem or database

If you’re already on JSF 2.2, you can do this by providing a custom ResourceHandler wherein you return the desired view resource in createViewResource(). public class FaceletsResourceHandler extends ResourceHandlerWrapper { private ResourceHandler wrapped; public FaceletsResourceHandler(ResourceHandler wrapped) { this.wrapped = wrapped; } @Override public ViewResource createViewResource(FacesContext context, final String name) { ViewResource resource = super.createViewResource(context, name); … Read more

How do you dynamically compile and load external java classes? [duplicate]

Take a look at JavaCompiler The following is based on the example given in the JavaDocs This will save a File in the testcompile directory (based on the package name requirements) and the compile the File to a Java class… package inlinecompiler; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.net.URL; import java.net.URLClassLoader; import … Read more

Android saving file to external storage

Use this function to save your bitmap in SD card private void SaveImage(Bitmap finalBitmap) { String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + “/saved_images”); if (!myDir.exists()) { myDir.mkdirs(); } Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String fname = “Image-“+ n +”.jpg”; File file = new File (myDir, … Read more

Find location of a removable SD card

Environment.getExternalStorageState() returns path to internal SD mount point like “/mnt/sdcard” No, Environment.getExternalStorageDirectory() refers to whatever the device manufacturer considered to be “external storage”. On some devices, this is removable media, like an SD card. On some devices, this is a portion of on-device flash. Here, “external storage” means “the stuff accessible via USB Mass Storage … Read more