I am new to java.
I am using this code
MyClass.class.getClassLoader().getResourceAsStream("myfile.properties")
to the values from property file.
Now i am storing the webdriver in a folder under project, would like to get the path dybamically, so im using this code:
MyClass.class.getClassLoader().getResourceAsStream("Drivers\\IEDriverServer_x64_2.50.0.zip")
but this returns null, can any one suggest me how to read the file/folder located under the project?
First of all check the location of the file you want to load inside the JAR and try using relative paths like
MyClass.class.getClass().getResourceAsStream("/yourFolder/myfile.properties")
OR
MyClass.getClass().getClassLoader().getResourceAsStream("/yourFolder/myfile.properties")
Related
I am new in lua and gmod coding. I have already coded successfully a HUD's addons but i am stuck in another.
I want to create a new entity, and after reading lots of tutorial, i manage to do it but in game, the word ERROR appears in red when spawning, not the model. The server and the client are located on the same PC, for debugging considerations. I try to put mdl files on several folders without aby change.
I put mdl file in
addons/models/model.mdl
I think the client doesn't find the model file : do i need a workshop content even for testing ? Where do i put the files ?
Thanks.
I got it. When reusing existing MDL file, i must keep the original path for files.
That is, when opening mdl file, a path is writing at the begining. This path must be the same in the models subfolder of the addons (path and filename).
So what I am trying to do is instantiating a .obj file locally stored on the device AFTER BUILD. I have searched for hours but in vain...
I already managed to make a file explorer in unity, which returns the URL of the selected .obj file. Then I use WWW(string url) load the object.
WWW bundleRequest = new WWW(#"file://" + pathName);
To this point, everything is perfect.
And here is my question: Is there a way to convert the text of the file, so bundleRequest.text to an instantiable GameObject AFTER BUILD? Through any means possible: APIs, extensions, etc.
Thank you in advance
This asset has helped me before, Runtime OBJ Importer, it's free too!
https://assetstore.unity.com/packages/tools/modeling/runtime-obj-importer-49547
I would like to assign a BitmapImage from my Resources.resx to an Image.
Beforehand I saved a .png image to Resources.resx. This image is now located in "/Resources/logo.png".
After reading several SO posts and other articles I have this now:
logoImage.Source = new BitmapImage(new Uri(#"pack://application:,,,/Resources/logo.png"));
Unfortunately it doesn't work.
I don't know how to solve this.
I tried to replace the Pack-URI with the fullpath and it worked but I would like to use relative paths in order to use the same source on different machines on which the absolute path would be incorrect.
Can anyone help me out with this?
In order to make that Uri work, the file logo.png must be contained in a folder named "Resources" in your VS project (see first image), and its Build Action must be set to Resource (see second image).
This Resources folder is completely unrelated to Resources.resx. You may rename it to whatever you like.
I am new in code name one. I have to add image in a container(flow layout) with specific width and height.
1: codenameone's guide says that we have to add image in resource folder. Where is that resource folder?
2: To create image i am using createImage(path) of image class. if we put image file in resource folder then what is path of that image.
3: Is here any type restriction of image file in it.
Please help.
When you put the image you would like to add in your src folder the code should look as followed:
Label i = new Label();
Image img = Image.createImage("/imageToAdd.png");
i.setIcon(img);
You can change the label to whatever object you would like to use to display your image.
Resource file not folder, the ".res" file in the root of the SRC directory contains your theme as well as additional images you might need. The value here is that you can add multi-images (see tutorial) as well as write very portable code.
You can access the resource file in a GUI builder via fetchResourceFile() or in a non-GUI builder app using Resources.open (as is demonstrated in the init method).
You can also place arbitrary JPG/PNG files in the src root next to the res file. While there is no restriction from Codename One, devices tend to support PNG/JPG well and might fail with other formats.
Which method of the File class can I use to return the absolute path of a text file whose name is already mentioned in the application. In other words, the name of the file or its relative path is not to be typed in by the user.
Either e.g. FileInfo.FullName in VB.Net
or I donĀ“t understand the question...