Questions tagged [resources]

Assets (like memory, disk space, CPU power or alike) necessary for effective operation or physical files (like images, configuration files or other) to provide some externalized enrichment to an application.

Typically resources are materials or other assets that are transformed to produce benefit and in the process may be consumed or made unavailable

9303 questions
142
votes
6 answers

How to get absolute path to file in /resources folder of your project

Assume standard maven setup. Say in your resources folder you have a file abc. In Java, how can I get absolute path to the file please?
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
140
votes
5 answers

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

I have just upgraded Tomcat from version 7.0.52 to 8.0.14. I am getting this for lots of static image files: org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/base/1325/WA6144-150x112.jpg] to the cache because…
iainmac999
  • 1,569
  • 2
  • 13
  • 12
138
votes
14 answers

Android read text raw resource file

I have a text file added as a raw resource. The text file contains text like: b) IF APPLICABLE LAW REQUIRES ANY WARRANTIES WITH RESPECT TO THE SOFTWARE, ALL SUCH WARRANTIES ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF …
Alin
  • 14,809
  • 40
  • 129
  • 218
134
votes
11 answers

Android OnClickListener - identify a button

I have the activity: 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); …
xpepermint
  • 35,055
  • 30
  • 109
  • 163
134
votes
5 answers

Setting Icon for wpf application (VS 08)

Before going much further i'll mention I have tried solutions in following: How do I set the icon for my application in visual studio 2008? Set application icon from resources in VS 05 I am trying to set an icon for my application. AFAIK, I need…
baron
  • 11,011
  • 20
  • 54
  • 88
132
votes
6 answers

Android: alternate layout xml for landscape mode

How can I have one layout for landscape and one for portrait? I want to assume extra width and conserve vertical space when the user rotates the phone over sideways.
700 Software
  • 85,281
  • 83
  • 234
  • 341
131
votes
6 answers

Java resource as File

Is there a way in Java to construct a File instance on a resource retrieved from a jar through the classloader? My application uses some files from the jar (default) or from a filesystem directory specified at runtime (user input). I'm looking for a…
Mantrum
  • 1,505
  • 2
  • 11
  • 9
124
votes
5 answers

Preferred way of loading resources in Java

I would like to know the best way of loading a resource in Java: this.getClass().getResource() (or getResourceAsStream()), Thread.currentThread().getContextClassLoader().getResource(name), System.class.getResource(name).
Doc Davluz
  • 4,154
  • 5
  • 30
  • 32
119
votes
5 answers

How can I discover the "path" of an embedded resource?

I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder…
Rob
  • 4,210
  • 3
  • 30
  • 25
116
votes
15 answers

Resource leak: 'in' is never closed

Why does Eclipse give me the warming "Resource leak: 'in' is never closed" in the following code? public void readShapeData() { Scanner in = new Scanner(System.in); System.out.println("Enter the width of the Rectangle: "); …
user1686995
  • 1,261
  • 2
  • 9
  • 3
110
votes
16 answers

Getting android.content.res.Resources$NotFoundException: exception even when the resource is present in android

Please let me know where I am going wrong to get the error. I am creating an app which have one of its activity to be only in landscape mode. So I added the following in AndroidManifest.xml file
Nik
  • 2,913
  • 7
  • 40
  • 66
106
votes
4 answers

What's the difference between a Resource and an Embedded Resource in a C# application?

When should I use one or the other? I'd like all of the files I use in my app (images, sound, xml file, etc.) to be inside of the .exe file so I don't deploy with a bunch of folders and files. Thanks for the info.
Sergio Tapia
  • 40,006
  • 76
  • 183
  • 254
104
votes
2 answers

WPF throws "Cannot locate resource" exception when loading the image

I am having a WPF window, with a background image of one file in my local system. So the XAML file looks like this: In the XAML…
tete
  • 4,859
  • 11
  • 50
  • 81
100
votes
4 answers

How to read file from res/raw by name

I want to open a file from the folder res/raw/. I am absolutely sure that the file exists. To open the file I have tried File ddd = new File("res/raw/example.png"); The command ddd.exists(); yields FALSE. So this method does not…
Bernd
  • 3,405
  • 3
  • 18
  • 21
94
votes
7 answers

Getting a list of files in the Resources folder - iOS

Let's say I have a folder in my "Resources" folder of my iPhone application called "Documents". Is there a way that I can get an array or some type of list of all the files included in that folder at run time? So, in code, it would look…
CodeGuy
  • 28,427
  • 76
  • 200
  • 317