Open file from a directory that is not web accessible?

Subject says it all really, I'd like users to be able to download files from a directory that is otherwise not accessible by the browser. There is a way to do this is PHP, the readfile() function. Is there something equivalent in Java?
Thanks!

You can do that with a Servlet and a shot of java.io API.
Here's an example: [http://balusc.blogspot.com/2007/07/fileservlet.html].

Similar Messages

  • How can I get a count of files in a directory that does not include subfolders?

    Information [Comand I] gives me an "items" number that includes subfolders; however, Box gives me a number that excludes subfolders and includes only files. I am trying to double check that I have migrated everything from a local directory to a Box; thus, I would like a way to a count of just the number of files in a local directory that does not include subfolders but rather is limited to files. This has been surprisingly hard to find.
    Thanks,
    Stu

    Sort the contents of the folder by Kind. While holding down the Shift key  click on the first and last file and start to drag them.  The number of the files being dragged will be displayed in a red circle.
    Not elegant but works.

  • Trying to access a file from a host that is not available

    If I try to access a file on a host that is not available/unreachable, it hangs up for about 5-10 minutes. Is there any way to speed this up? I am using JDK 1.4.2
    String filename = "\\\\ip\\myFile.txt"; // ip address is unreachable
    File f = new File(filename);
    f.exists(); // hangs hereTIA,
    DB
    Edited by: Darth_Bane on Aug 14, 2009 9:33 PM
    Edited by: Darth_Bane on Aug 14, 2009 9:34 PM

    I think you can use an IP address in the File spec. Windows allows you to use the IP address rather then the hostname in a // address (UNC?) infact its faster to use the ip over the hostname (windows networking is SLOW anyway)
    Why not try dertimining if the machine is connected to the network before trying to get the file? There is something in the NetworkInterface API about pinging a IP or was that in the Socket API. eitherway, i think finding out if the computer is available before the file would make sense, that way you arnt waiting arround to find out if the file on an unavailable machine isnt there when you know the machine isnt online.
    Thats my two cents.

  • A script to open files in a directory that have certain properties

    I need a script to open all JPG files in a directory and it's subfolders that have a height greater than the width and then run a specific photoshop action for each (inlcuding a save for web within the same directory). Not sure if it's best to record that into the action as it will probably always try to save in the same directory. Probably need something similar to the batch options available in Photoshop that override this...
    Any help is much appreciated.

    I think I found what I'm looking for in ImageReady although I'm not sure how to set it to batch. I don't see the batch command in the File menu like Photoshop...

  • How can I free up space by deleting old photos from i photo? Have deleted files from iPhoto but that does not seem to free space- is it stored at a different site?

    Want to free up disk space by deleting photos but unable to do so

    To delete photos from iPhoto:
    Drag the image from the iPhoto Library (Either Events or Photos view) to the iPhoto Trash. Empty it. Then empty the system trash as well.
    If space is an issue you can run a Library from an external drive:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Or move part of the Library to an external drive.
    Regards
    TD

  • Open files from a specific directory

    Dear all,
    I have the following source code that simply selects files from a directory.
    private void openFile()
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(
    JFileChooser.FILES_ONLY );
    int result = fileChooser.showOpenDialog( this );
    // user clicked Cancel button on dialog
    if (result == JFileChooser.CANCEL_OPTION )
    return;
    File filename = fileChooser.getSelectedFile();
    if (filename == null || filename.getName().equals( "" ))
    JOptionPane.showMessageDialog( this,
    "Invalid File Name",
    "Invalid File Name", JOptionPane.ERROR_MESSAGE );
    else
    // open the file
    try
         // Open an input stream
         FileInputStream fin1 = new FileInputStream(filename);
    // Read and print a line of text
    BufferedReader d1 = new BufferedReader(new InputStreamReader(fin1));
    abs = d1.readLine();
    outputArea1.setText("");
    outputArea1.append(abs + "\n\n");
    outputArea1.setCaretPosition(0);
    // Close our input and output stream
    fin1.close();
    catch (IOException e5) {
    JOptionPane.showMessageDialog(this, "Error Opening File", "Error", JOptionPane.ERROR_MESSAGE);
    } // end catch
    } // end else
    } // end private
    My question is: Can I force it to open files from a specific directory, and NOT from MyDocuments directory????
    thanks,
    vxc

    \r = return
    \n = linefeed
    \j = illegal escape character
    JFileChooser fileChooser = new JFileChooser("C:\j2sdk1.4.2\bin");
    You could/should use:
    (new File).pathSeparator
    or
    (new File).pathSeparatorChar
    and
    (new File).separator
    or
    (new File).separatorChar
    http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html

  • How to open and read many files from a directory and store contents in 2D array?

    I want to make a VI that opens and reads the data from various files contained in a directory (200 files each with 2 columns) and store these in a single 2D array. For file number 1 I want to store the data from both columns in the 2D array, but for files 2 to 200 I only want to store the second column of each file. Can someone please help?

    Hi Nadav,
    Thanks for your help. I have followed your instructions but i cannot get it to work. I used the LIST DIRECTORY to list the files in the directory - that works. However, how do I read each of the 200 files using READ FROM SPREADSHEET FILE without me having to manually select each of the 200 files? So, if I use LIST DIRECTORY to list all 200 files in an array, how do I get each of these to open and store the data in a 2D array? Here is what I have done (File called read_files.VI) Could you please help me? Thank you very much in advance.
    Attachments:
    read_files.vi ‏18 KB

  • PI sender communication channel not reading files from NFS directory

    Hello,
    I have a sender communication channel configured to read file from NFS directory which is on ECC server. A program in ECC generates the file and puts it on the ECC server in the output directory. PI sender communication channel is supposed to pickup this file and process it. If I give the NFS path as the source directory, I am getting error: Configured source directory '//Server/DIR/OUT' does not exist. I tried putting '
    Server\DIR\OUT' too but same error. Do I have to add the NFS path of ECC into PI as logical path?
    Any suggestions?
    Thanks,
    Sangita

    Hello Sangita,
    Your ECC server is an external system, therefore you need to activate FTP service in that system and use the transport protocol FTP:
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
    You can use NFS protocol when you have a local directory in XI server.
    Best Regards,
    .Luis Bernal.

  • Photoshop CS3 lauches but does not open files from Lightroom 2.7

    These programs have been on my computer since the dawn of time and have always worked. Now all of a sudden I can't open files from LR into PS. PS launches, but the files don't open. I get that message Photoshop could not be lauched, which is ironic since the program is now open.
    I haven't done anything to the programs so it makes no sense. IN the past I have had issues with PS and the tech had me create a new login on my computer and it fixed things. Tried that. No help.
    Does anyone ahve any suggestions. I have repaired both programs to no avail.
    Thanks for you help.

    Something has gone wrong with how Lightroom finds and communicates with Photoshop.
    That could be a registry string, or some preference within Lightroom.
    The Lightroom forum is more likely to be able to help you solve this.

  • Can the new garageband open files from the previous garageband? in my case it seems not to work and I would like to know if it is possible at all...

    Can the new garageband open files from the previous garageband? in my case it seems not to work and I would like to know if it is possible at all...

    No.
    I find it extremely frustrating that Apple does not care for such an obvious bug affecting one of the basic funcionalities of AirPlay. Unless, of course, if there's something I don't know - but I've done some research and it seems that plenty of people have same issue and no solution is settled.

  • Hi, I just downloaded and installed Photoshop cc and the Camera Raw version is not the latest one available,so now I can no longer open files from my Nikon D750!  Can I update ACR?

    I just downloaded and installed Photoshop cc and the Camera Raw version is not the latest one available,so now I can no longer open files from my Nikon D750!  Can I update ACR?
    I have been using the new version of ACR with PS6 and have been able to open the D750 files,now I'm stuck.
    Thanks,
    Greg E

    You were probably using the Release Candidate version of camera raw 8.7, which one gets from Adobe Labs.
    http://labs.adobe.com/technologies/cameraraw8-7-cc/index.html

  • PSCS6 no longer recognizes my CR2 files and will not open. Using Canon 5DMark III with updated Camera Raw . It has worked before but now won't open files from this camera.

    I have been able to open files from this camera before but still checked for latest Camera Raw download. Still won't open files from this camera. Opens files from my 60D just fine. I downloaded the latest and it has worked before. What the heck is going on?

    Glad to be of help. But I'm curious (not critical of what you are doing) to know why so many people like to use Nikon Transfer to transfer their files to the computer. It is still necessary to import them into Lightroom. And, from my perspective, it seems simpler and maybe even a little quicker to use the Lightroom import dialog. I have Nikon cameras, and have never even installed the Nikon Transfer utility. What is so unique about it?

  • FTP Adapter to read multiple files from a directory. Not through polling.

    Dear Friends,
    I would like to know is it possible to configure the FTP adapter in Oracle BPEL 10.1.3.4 to read multiple files (different names, same structure) from a given directory. I do not want the BPEL to do a polling. Instead when I submit the BPEL process it should read all files from the directory.
    I was looking at the option of Synchronous read but I am not able to specify wild card in the file name field. I do not know the file names at the time of reading.
    Thanks for your help!

    Hi,
    While you read the file, you can configure an adapter property in 'Receive'. This will store the filename, this filename can be used for sync read as the input parameter.
    1. Create a message type variable called 'fileheader'. This should be of type Inboundheader_msg (whatever relevant Receive activity).
    2. This variable will contain three parts - filename, FTPhost, FTPPort
    3. Copy this fileheader to 'Syncheader'.
    4. syncheader can be passed as an adapter proerty during sync read of the file.
    During Receive and Invoke, you need to navigate to 'Adapter' tab to choose the created message type variable.
    Let me know if you have further questions.
    regards,
    Rev

  • Why can't I open and retrieve my files from iPhoto and my address book after importing the files from my Power mac G5 to my new Mac Pro? I get a warning that says the new OS on my Pro doesn't open files from a Power Mac. Any idea how I can fix this?

    Why can't I open and retrieve my files from iPhoto and my Address Book after importing the files from my Power Mac G5 to my new Mac Pro? I get a warning that says the new OS on my Pro doesn't open files from a Power Mac. Any idea how I can fix this?

    For your addressbook, export the files to vCard on the PowerMac, then bring them over to your Mac Pro. For your iPhoto, copy the Users -> yourname -> Pictures folder to your Desktop on the Mac Pro, and open iPhoto on the Mac Pro holding the command and option keys.  Select the library file from that Pictures folder and open it.  It should import all the pictures into iPhoto as part of the rebuild process.  Other PowerPC to Intel migration issues are covered here: https://discussions.apple.com/docs/DOC-2295

  • Reading only Image files from a directory

    i am wanting to be able to read a directory but only obtain the Image files (ie, gif, jpeg, tiff, png etc) and ignore all other type of files.
    i have made a custom ImageFIlter class which extends FileFilter which works for adding a photo singly, as only image files are shown in the JFileChooser. however i am wanting to add a folder of photos at once.
    here is the code so far:
    File dir;
                        JFileChooser fc = new JFileChooser();
                        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                        //Handle open button action.
                        int returnVal = fc.showOpenDialog(MainAppGUI.this);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                             dir = fc.getSelectedFile();
                             if (dir.isDirectory()) {
                                  File[] files = dir.listFiles(new FileFilter());
                                  for (int i = 0; i < files.length; i++) {
                                       if (files.isFile()) {
                                            try {
                                                 Photo PhotoAdded = workingCollection.addManyPhotos(files[i], canvas.getChangedMaxDim());
                                                 //need to also add it to the relevant vectors, ie
                                                 //for mouse over operations, or photos added after
                                                 //save.
                                                 if(!workingCollection.isDuplicate()){
                                                      photosToCheck.add(photoAdded);
                                                      canvas.addToGrid(photoAdded);
                                                      photosAddedAfterLoad.add(photoAdded);
                                                      canvas.repaint();
                                                 else{
                                                      //do nothing as it is already in the vectors.
                                            } catch (Exception er) {
                                                 // Do nothing. Bad mp3, don't add.
                                       // recurse through directories
                                       else {
                             } else {
                                  try {
                                       throw new IOException(
                                                 "Error loading files from a directory: "
                                                           + dir.getAbsolutePath() + " is not a "
                                                           + "directory");
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();
    any ideas?

    it shouldnt be new FileFilter() there, it should be new ImageFilter() but it gives a compilation error saying i cannot apply that parameter to the listFiles() method in the File class

Maybe you are looking for

  • Problem in posting Custom fields in Purchase Order using BAPI_PO_CREATE1

    Hi friends, Did any body tried populating custom fields using BAPI_PO_CREATE1? I am trying to populate custom fields in Header. I am populating EXTENSIONIN-STRUCTURE with 'BAPI_TE_MEPOHEADER' and EXTENSIONIN-VALUEPART1 with respective values of field

  • 2 MACs - Can I use .mac to sync POP emails from MAIL when traveling

    I use Yahoo Business (POP) email with the MAC MAIL software. I use a PowerBook G4 at home and just got a new iBook G4 for travel. I want to set up the travel computer and MAIL to receive and send mail while on the road. 2 Questions: 1) In a perfect w

  • To know IP address and port no using DB Link

    Hi - Is it possiable to know the IP address and port no of other oracle database that are connected with DB link. i.e for example we have 2 oracle databases(For example A and B and it's schemas are A_A and B_B) on two different IP address and DB link

  • Nano7 changes my library's artist name

    i edited the  artist info in my library  so that "john cougar"& "john cougar mellencamp" are all consistently titled "john mellencamp".  on my iphone, this works great.  there's just one artist entry for him (even though his albums have 3 different v

  • Can I buy a Mac with a Turkish keyboard in the States?

    Hi, I was wondering if I could buy a MacBook Pro with a Turkish keyboard while I'm in the States? In the store you can choose whether you want an English, Spanish, Japanese or a French keyboard, is this possible for any other language such as Turkish