Java resource as File

I had the same problem and was able to use the following: // Load the directory as a resource URL dir_url = ClassLoader.getSystemResource(dir_path); // Turn the resource into a File object File dir = new File(dir_url.toURI()); // List the directory String files = dir.list()

Android: alternate layout xml for landscape mode

By default, the layouts in /res/layout are applied to both portrait and landscape. If you have for example /res/layout/main.xml you can add a new folder /res/layout-land, copy main.xml into it and make the needed adjustments. See also http://www.androidpeople.com/android-portrait-amp-landscape-differeent-layouts and http://www.devx.com/wireless/Article/40792/1954 for some more options.

Android OnClickListener – identify a button

You will learn the way to do it, in an easy way, is: public class Mtest extends Activity { Button b1; Button b2; public void onCreate(Bundle savedInstanceState) { … b1 = (Button) findViewById(R.id.b1); b2 = (Button) findViewById(R.id.b2); b1.setOnClickListener(myhandler1); b2.setOnClickListener(myhandler2); … } View.OnClickListener myhandler1 = new View.OnClickListener() { public void onClick(View v) { // it was … Read more

Tomcat 8 throwing – org.apache.catalina.webresources.Cache.getResource Unable to add the resource

I had the same issue when upgrading from Tomcat 7 to 8: a continuous large flood of log warnings about cache. 1. Short Answer Add this within the Context xml element of your $CATALINA_BASE/conf/context.xml: <!– The default value is 10240 kbytes, even when not added to context.xml. So increase it high enough, until the problem … Read more

Android read text raw resource file

You can use this: try { Resources res = getResources(); InputStream in_s = res.openRawResource(R.raw.help); byte[] b = new byte[in_s.available()]; in_s.read(b); txtHelp.setText(new String(b)); } catch (Exception e) { // e.printStackTrace(); txtHelp.setText(“Error: can’t show help.”); }

Correct way to quit a Qt program?

QApplication is derived from QCoreApplication and thereby inherits quit() which is a public slot of QCoreApplication, so there is no difference between QApplication::quit() and QCoreApplication::quit(). As we can read in the documentation of QCoreApplication::quit() it “tells the application to exit with return code 0 (success).”. If you want to exit because you discovered file corruption … Read more

References to other resources are not supported by build-time PNG generation

To support API SDK < 24 add the following line to your app build.gradle inside the android block: defaultConfig { vectorDrawables.useSupportLibrary = true } If your minSdkVersion is 24 or higher, then your issue will be resolved on its own, because VectorDrawables have full support starting with this API. See Android Developers: Vector Drawables Backward … Read more

What is in your Mathematica tool bag? [closed]

One of the nice things about the Mathematica notebook interface is that it can evaluate expressions in any language, not just Mathematica. As a simple example, consider creating a new Shell input cell type that passes the contained expression to the operating system shell for evaluation. First, define a function that delegates evaluation of a … Read more

How can I access a folder inside of a resource folder from inside my jar File?

Finally, I found the solution: final String path = “sample/folder”; final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); if(jarFile.isFile()) { // Run with JAR file final JarFile jar = new JarFile(jarFile); final Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar while(entries.hasMoreElements()) { final String name = entries.nextElement().getName(); if (name.startsWith(path + “https://stackoverflow.com/”)) { //filter according to the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)