Questions tagged [getresource]

283 questions
0
votes
1 answer

Cant add custom font with using .getResource() - Java

I am going to convert my project into jar file. I am setting all my images and other external files with this.getClass().getResource(""); I have no problem with adding images; xButton.setIcon(new…
Lunatic Fnatic
  • 661
  • 2
  • 6
  • 17
0
votes
1 answer

Getting location of file as string in resource folder

I have completed a program in eclipse and now I would like to export it as a single runnable jar file. The program contains a resource folder with images and text files in it. This is located beneath the source folder. The res file is not added to…
Patch
  • 203
  • 2
  • 3
  • 6
0
votes
2 answers

getResourceAsStream() returning null

I have a java .jar library, and from there i'm trying to access a file of my Android project with: InputStream inputStream = getClass().getResourceAsStream("/folder/data.txt"); someMethod(inputStream); // inputStream is null But the inputStream is…
ILovemyPoncho
  • 2,762
  • 2
  • 24
  • 37
0
votes
0 answers

I can't load image and text in some platform from res/raw

I have layout that my images and text files in "res/raw" folder are load by user search. image's name start with ("p"+month+"_"+day) and the text file start with "t". when user search date java create file name by month and day. but this is not show…
0
votes
1 answer

Iterate through certain images in res/drawable-mdpi

In the res/drawable-mdpi folder I have 26 letter images, named big_0.png to big_25.png. I would like to add them all (and ignore any other images in the folder) to a hash map: private static HashMap sHash = new…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
0
votes
2 answers

why can not I set drawable to find the package name?

I can not understand what is the error that I have, what I did wrong? I have followed the various tutorials on the internet for how to set up an image from drawable, because it does not work? Drawable drawable = mContext.getResources().getDrawable( …
Nick Pass
  • 80
  • 8
0
votes
1 answer

Awkward result while reading file containing spaces in pathname using getResource() in java

I have a project named Downloader containing files like this: Downloader -->src -->Downloader -->DownLoader.java -->AudioLinks I have tried to access AudioLinks from Downloader.java by the following function. public void…
FRR
  • 99
  • 8
0
votes
1 answer

getResources() stops working when moved into package

The test method below passes when my test class is in the default package and fails when I move it into a package. The directory structure is the following: src/ main/ java/ some.package/ resources/ test/ FooTest.java // works…
AnthonyW
  • 1,910
  • 5
  • 25
  • 46
0
votes
2 answers

Java - copy Jar Folder

Actually I am confronted with a Problem. I've got a ".apk-File" in one Package of my Application. apk is a kind of a jar File (apk = Android Package). I now want to copy this jar-file out of my Programm onto any other Location at the PC. Normally I…
Ripei
  • 432
  • 2
  • 8
  • 19
0
votes
2 answers

java netbeans getClass().getResource(filename) return null

I have a picture resource in my netbeans project and the getResource(...) method returns null, for every combination. Can you see what I am doing wrong from this screenshot?
user2302244
  • 843
  • 2
  • 11
  • 27
0
votes
2 answers

Why is getResourceAsStream returning null?

I have an image inside my jar which I am trying to load, but getResourceAsStream() always returns null. Directory structure: com/thesimpzone/watch_pugs/watch_pugs/{all my class…
Oscar S
  • 23
  • 1
  • 7
0
votes
1 answer

Jetty servlet override extension reading file

I'm trying to make a servlet on Jetty that overrides a file extension but that still needs to read the file being accessed. I've been trying with resources but I could achieve nothing yet. I've tryed this code so far and, as you'll see, the…
valarion
  • 45
  • 3
0
votes
3 answers

Why I'm getting different results using url and absolute file name?

I am new in Java and facing a problem aceessing a file. I have a package named "FileOperation" uses a "boom.txt" file(Location: "FileOperation/files/boom.txt"). What I wanted to do was to access the file from a class "MyTextPanel" (Location:…
FRR
  • 99
  • 8
0
votes
2 answers

Can't access resources from same directory in several projects with Class.getResource in eclipse

I use maven to create a runnable jar from multiple projects : Project A (contains the Main class): /src/main/resources/META-INF/resources/a.txt Project B (depends on Project A): /src/main/resources/META-INF/resources/b.txt Runnable.jar…
0
votes
2 answers

Java Load resources (images, audio, text files etc) without the use of "/" sign due to portability issues and use File.separator

I am rewriting my classes that loads resources inside of my game. My professor told us to try not to use "/" slash sign in our Strings/File/URL when loading our resources. I am using Classname.class.getResource(someString) to get URLs so I can load…
Towni0
  • 87
  • 1
  • 6