Loading file using a path writen in edit box matlab - matlab

hello evryone
wanna load file from a specific path writen in an edit box named by 'Load_text', i got the path from the edit box using :
pth=get(handles.Load_text,'string');
then i used 'dir' as follow:
S=dir(fullfile([pth '*.bmp']));
that what cause me an errur . so any ideas ?

If you want to load a file then why you are using dir?
Since you have the file's name, then you can create the fullpath as you do with the fullpath method and check its existence with exists.
If the file exists, then you can load it with all available methods from MATLAB.
Keep in mind that this means that the file is in the same directory as your GUI files. If it is in another then you will have to add it in the fullpath call.
fullpath online doc: http://www.mathworks.com/help/matlab/ref/fullfile.html
exists online doc: http://www.mathworks.com/help/matlab/ref/exist.html

Related

tfileproperties not working in my case in talend open studio

I want to fetch file details like path of file, column names, and other things .In my job there are null values while using tfileproperties as shown in image added. look
if somebody can do something.
To Use tFileProperties you have to pass a valid file Path
What i suggest is to pass the file Path in a context variable as such
Then , pass the context variable in my case file_Input in the tFileProperties as such :
And if your files are stored in the same Folder you can use a tFileList component see the link below :
https://help.talend.com/r/en-US/7.3/tfilelist/tfilelist-standard-properties

Scala: Create File with a Folder Using Relative Path (Not Absolute Path)

In my Scala code I want to create a folder "c:/temp" and then create a file "file.txt" within that folder. I don't want to have to use "c:/temp/file.txt". So, I want to use the relative path of the file to create it within that folder.
Imagine how a human creates a folder and then a file? He creates a folder; goes in the folder, and then creates the file inside that folder. That's what I want to do.
=====
Added the following to make this more clear:
Let's say I created the folder and I have a File object called myFolder that represents that folder. What I want is to be able to do something like myFolder.createFile("file.txt").
val subFile = new File(myFolder, "file.txt")
From the description of the File(File parent, String child) constructor found at the docs page:
Creates a new File instance from a parent abstract pathname and a child pathname string.

How can I rename file uploaded to s3 using javascript api?

'pickAndStore' method allows me to specify full path to the file, but I don't know it's extension at this point (file path has to be defined before file is uploaded, so it's not possible to provide a path with correct extension).
if I use 'pick' and then 'store' I have 2 files (because both methods uploads file to the s3). I can delete 'old' file, but it's not optimal and can be pain (take ages) with really big files.
Is there any better solution? Ideally to rename existing file.
Currently, there is no workaround for renaming file.
However, in our Javascript API v2 we are planing to add new callback function. onStart callback will be fired after user pick file but before file uploading. There could be option like renaming file based on original filename.
We will keep you updated.

Exporting an JAR file in Eclipse and referencing a file

I have a project with a image stored as a logo that I wish to use.
URL logoPath = new MainApplication().getClass().getClassLoader().getResource("img/logo.jpg");
Using that method I get the URL for the file and convert it to string. I then have to substring that by 5 to get rid of this output "file:/C:/Users/Stephen/git/ILLA/PoC/bin/img/logo.jpg"
However when I export this as a jar and run it I run into trouble. The URL now reads /ILLA.jar!/ and my image is just blank. I have a gut feeling that it's tripping me up so how do I fix this?
Cheers
You are almost there.
Images in a jar are treated as resources. You need to refer to them using the classpath
Just use getClass().getResource: something like:
getClass().getResource("/images/logo.jpg"));
where "images" is a package inside the jar file, with the path as above
see the leading / in the call - this will help accessing the path correctly (using absolute instead of relative). Just make sure the path is correct
Also see:
How to includes all images in jar file using eclipse
See here: Create a file object from a resource path to an image in a jar file
String imgName = "/resources/images/image.jpg";
InputStream in = getClass().getResourceAsStream(imgName);
ImageIcon img = new ImageIcon(ImageIO.read(in));
Note it looks like you need to use a stream for a resource inside an archive.

how to give the default path in gwt

i m creating a project in gwt (point) is project name ...
i want to store a image in point/war/images folder, whaich i gave the full path like C:\Documents and Settings\computer\workspace\m\war\images\ tthe the iamge will stored in images folder but i want to give the default path
i give "../war/images/" as default path, but this give me error (he system cannot find the path specified )
can any body help to give the default path
Usually you put images in the war/images directory, and you access them like
Image img = new Image("images/my_image.jpg")
You may also read this thread, and this question.