I need to connect to a windows shared drive so I can make a directory and then some files in that directory. I am not sure how I would go about this. Can you use any built in classes for java?
If you map the drive onto your machine you should be able to access the drive with the normal filepath "(Drive Letter):/"
Depending on your network configuration you might also be able to use the filepath "\(Server name)\"
Related
I want to access a file server that is not present in my network, but I have credentials of other domain that can be used to access the file.
How do I gain access to the file in share?
Is it possible to gain access to the file using a java program?
Operating System is Windows. I want to read the contents from .txt and .csv files present in the share and display it on a web page.
I used jcifs library to solve this. It works great.
You can use ftp protocol.
And also can make a map drive from share folder on your system. It's a simple solution.
I saw answer mentioned by Gord in
Unable to connect to a database on a shared drive - UCanAccess.
I am able to access my db from Windows to Windows Server where my Access Database file resides.
But when I deploy the same code on Unix, I am not able to access my database. I am using the same URL as proposed by Gord.
My URL is:
datasource.crr.url=jdbc:ucanaccess://////abc.dch.com\\der\\Share\\SongUnflaggedTest\\Songs\ Unflagged.accdb;Skipindexes=true;memory=true.
Unlike Windows, most Linux/Unix environments are unable to directly access a file in a shared folder by simply using its UNC path, e.g.,
\\server\share\folder\file.ext
Instead, we normally have to tell the Linux/Unix box to mount the share at a point on the local filesystem (sort of like assigning a drive letter in Windows), and then use that as the starting point.
For example, if we mount the share
\\server\share
to a mount point on the local filesystem named
/mnt/servershare
then we can access the file using the path
/mnt/servershare/folder/file.ext
See this Ask Ubuntu question for an example.
I have developed a website, one of its operation is to read and write data to text files stored at my local machine such as D://test.txt or C://file.txt, but now I am going to host my website at the external server, i mean over the internet use, i wonder where to keep these files that are associated with read and writing operations. At present I am getting an exception file not found if i am using my local machine location. For your information, I am using GlassFish server.
You will want to create a system property on Glassfish, which represents the file path and name. Then upload the file to that location of your choosing on the server where your website application is deployed.
Depending upon your needs, you may find it easier to deploy the file out with your application. Make sure the file is on the classpath, and you can load it using any number of ways.
We have a web application that allows user to download a zip file from a web server. We just provide dummy iframe source to the full URL of zip file on web server. This approach would allow end user to use browser controls which allows the user to open or save the zip to user's local machine.
We have a requirement that the zip file is automatically extracted and save to a specific location on user's machine. Any thoughts on how this can be achieved?
Thanks.
I highly doubt that you'll be able to do that. The closest you're likely to get is to generate a self-extracting executable file (which would be OS-dependent, of course).
I certainly wouldn't want a zip file to be automatically extracted - and I wouldn't want my browser to be able to force that decision upon me.
Short answer is I don't believe this is possible using the simple URL link you've implemented.
Fundamentally the problem you have is that you have no control over what the user does on their end, since you've ceded control to the browser.
If you do want to do this, then you'll need some client-side code that downloads the zipfile and unzips it.
I suspect Java is the way to go for this - Javascript and Flash both have problems writing files to the local drive. Of course if you want to be Windows only then a COM object could work.
Instead of sending a zip file why don't u instruct the web server to compress all the web traffic and just send the files directly?
See http://articles.sitepoint.com/article/web-output-mod_gzip-apache# for example.
I'm trying to create a zip file from a directory in Java, then place that file on a remote server (a network share). I'm currently getting an error because the Java File object cannot reference a remote location and I'm not really sure where to go from there.
Is there a way to zip a directory in Java to a remote location without using the File class?
Create the ZIP file locally and use either commons-net FTP or SFTP to move the ZIP file across to the remote location, assuming that by "remote location" you mean some FTP server, or possibly a blade on your network.
If you are using the renameTo method on java.io.File, note that this doesn't work on some operating systems (e.g. Solaris) where the locations are on different shares. You would have to do a manual copy of the file data from one location to another. This is pretty simple using standard Java I/O.