Problem in copy the file from WAR

I have the following requirement.
I have one file in WAR file which is to be copied to sme location in server during Server start after deployment.
I am using one servlet, which is being loaded during startup. I have written the code in "init" method of servlet.
try {
String fontFolderString = config.getServletContext().getInitParameter("WORKING_FOLDER")+ "\\fontFolder";
BufferedInputStream bis = (BufferedInputStream)this.getClass().getClassLoader().getResourceAsStream("\\image\\a.jpg");
File in = new File("");
File out = new File(fontFolderString);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(in));
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(out));
byte inArr[] = new byte[bis.available()];
int size = bis.read(inArr, 0, inArr.length);
bos.write(inArr, 0, size);
bis.close();
bos.close();
} catch (Exception e) {
     e.printStackTrace();
}image folder as mention in the line "BufferedInputStream bis" is in the directlry where servlet is there.
Here "bis" is being returned as null.
Please provide me the pointers what is wrong above
~Aman

The line of code
getClass().getClassLoader().getResourceAsStream("\\image\\a.jpg");searches the file a.jpg inside a dicrectory image located in the classpath of the web application. For example in web-inf/classes... The position of the servlet is insignificant.
If you are looking for the file in the web context (for example in the image folder of your web application you should use:
config.getServletContext().getResourceAsStream("\\image\\a.jpg");

Similar Messages

  • How can I copy my Itunes-library from Iphone to my new Mac, as I forgot to copy the files from the old PC, and now it is to late. I only have music on my Iphone.

    How can I copy my Itunes-library from Iphone to my new Mac, as I forgot to copy the files from the old PC, and now it is to late. I only have music on my Iphone4. Thank you.
    gunnarfromhovik

    For iTunes purchases only..
    Connect the iPhone to your Mac, launch iTunes.
    If you haven't done this yet, go to the iTunes menu bar click Store / Authorize This Computer
    Now from the iTunes menu bar again, click File / Transfer Purchases From...

  • Problem while dowloading the file from Application Server

    Dear Experts,
                 I am facing the Problem while downloading the file from Application server.
    We done the automatic function while saving the invoice, this will create an idoc, and this idoc is written in the Application Server.
    I am running the Transaction AL11 and select the record, and from menu --> List, i am downloading into TXT format.
    But for some segments, the length is long, and so the last 3 to 4 fields values are not appearing in the File. Even though i am unable to view the values in the file before downloading. But i can view in IDOC.
    Please help me to solve this issue.
    Thanks & Regards,
    Srini

    but our user will use the Txn. AL11 and they will download from there
    Educate the user On a serious note, tell him this is not how data from app server should be downloaded. You can ask him to talk to the basis team to provide him access to the app server folder where the file is being stored.
    I can set the Variant and put this in background, But always the file name will be change, Like we use Time stamp in the File name.
    You can't automate this process by scheduling in BG mode. This is because the in BG mode you can't dwld the file to presentation server.
    Hope i'm clear.
    BR,
    Suhas

  • Problems during copying music files from iTunes 10.6.1 to iPhone

    1st problem
    In new iTunes 10.6.1 on my MBP when copying music on iPhone if during copying add additional musical files in queue, copying of files from the previous queue stops. In the previous iTunes version of such problem didn't arise. Whether there is a solution of this problem?
    2nd problem
    In older version of iTunes i could adding new music files to my iphone with drag and drop from Finder. Now i must add files in iTunes library and then from library drag and drop files to iphone. How to solve this problem?

    You would have to purchase 10.6 (Snow Leopard) and install it, assuming your computer is compatible.

  • Problem while reading the file from FTP server

    Hi Friends,
    I have a problem while fetching files from FTP server.
    I used FTP_Connect, FTP_COMMAND function modules. I can able to put the files into FTP server.
    but I cant able to pick the files from FTP server.
    anyone have faced similar issues kindly let me know.
    Thanks
    Gowrishankar

    Hi,
    try this way..
    for reading the file using FTP you need to use different unix command ..
    Prabhuda

  • I had to transferr my music files from one computer to another by directly copying the files from the hard drive to a new drive.  Itunes recognized the files and I was able to load in new songs.  The new songs won't sync with ipod.  Ideas?

    To copy the files I had to remove the hard drive and direct copy them to an expansion drive on another machine.  ITunes recognized the copied files and operates correctly on the computer.  I was able to download additional songs to ITunes on the computer without problem.  The IPod however will not recognize the new songs, does an abreviated sync process and gives a message that the IPod cannot sync because files are being used by another application.  It is also does not want to accept the disconnect command.  Any suggestions on how to solve the sync problem?

    how did you save the songs? can you play the songs? have you restarted the computer?

  • Problem in copying the file

    i had created a frame in which iam getting a source file and then copies the file to certain location...the problem is when i copy a large file it is doing well for the first time but when the second time while iam copying exception occurs like this
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    iam using the code
    public static void copy(File source, File dest) throws IOException {
         FileChannel in = null, out = null;
         try {         
              in = new FileInputStream(source).getChannel();
              out = new FileOutputStream(dest).getChannel();
              long size = in.size();
              MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
              out.write(buf);
         } finally {
              if (in != null)          in.close();
              if (out != null)     out.close();
        }how to solve this

    Do you simply want to copy the file. Try, not using many non-instrictive data types, because these use many extra variables and you end up using a lot more memory than you would have req.
    Eg-
    public void copy(File source,File dest) throws IOException{
         FileInputStream fins=new FileInputStream(source);
         byte[]b=new byte[(int)fins.length()];
         fins.read(b);
         fins.close();
         FileOutputStream fos=new FileOutputStream(dest);
         fos.write(b);
         fos.close();
    }This is code is not a solution, because here i am reading all file at once. This is basically to show you a method.
    In real situation you can set the size of byte[]b to 1024, and loop util read(b); method returns -1.

  • UDF to copy the file from the archive folder to the source folder

    HI,
    I need a UDF to copy the xml file from the archive folder to the source folder. I dont want to create a new comm channel
    Regards,
    Varun
    Edited by: Varun Reddy on Sep 15, 2009 11:23 AM

    Hi Varun,
    do you want to copy or move the files??
    Also can you explain the time when this movement should happen? this gives a little insight on the problem and also some optimum solutions can be suggested
    Regards
    Suraj

  • Problem in copying the file to right directory

    Hi
    I am trying to copy a file uploaded by the user to a new directory. the dir structure is
    /data/temp/username/. The username dir is created at the time of upload. so if any user with the username say "bob" logs in, a directory bob is created under /data/temp.
    the file uploaded by the user needs to be stored under "bob" dir ....in my case its being stored in /data/temp.
    When i try to print file.getAbsoluetPath it shows me as the file is stored under bob....so i get /data/temp/bob/filename.doc
    but when i check the dir the file is actually stored under temp & not bob.
    Can anyone help please..
    Thanx

    Hi there
    Thanx for you reply.
    I read the snippet, but it says about Windows, I am working on Linux. Wont that make a diference when i getAbsoluetpath.. Coz the print statement shows me the path as /data/temp/username
    Also i ran a prototype of the code on windows and it seems to work fine ... like it creates a user directory under C:/Java/temp and then stores the file under the new created user directory.
    If the code would help to think in a better way heres it:
    /* tempdir is already defined in config file as /data/temp .. I am just calling it here to create
    the new directory under it.. this line works fine */
    File usrDir = new File(tempDir, username);
    boolean dirMade = usrDir.makeDir();
    String path = dirMade.getAbsolutePath();
    File fupload = new File(path, fileName);
    /* in the above line, fileName is the name of the file uploaded by client (user) */
    String filepath = fupload.getAbsolutePath();
    /* in tha bove line gives the path as /data/temp/username/filename.ext */
    but when i go to the directory its actually stored as /data/temp/username and /data/temp/filename.ext
    Any suggestions please
    Thanx

  • How to copy the file from firebird database to SQL server

    Hi all,
    I have a file in Fire bird Database (30 GB with .ydb extension).  which needs to be restored to SQL Server. I Have created a linked server and done it but it is taking very long time to update the
    records. Can any one please suggest if u have any alternate method to do this.
    Thanks in Advance
    Regards,
    Balaji Prasad B
    Balaji - BI Developer

    Can you try doing it in two steps?
    1. Downloading file to a shared folder path
    2. Uploading file from path to SQLServer using bulk options like OPENROWSET...BULK
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Help copy large file from iPhone to PC

    Hello Everybody.
    I’m coding the Record application. However, I have problem with copying the file from iPhone device to the PC after recording. I used Attach File function on Email but it doesn’t allow with large size > 10MB file. I haven’t found any solution yet for this problem. iTune 9.0 has “Include Voice Memos” function, can i do the same with my application ? “Include My App” e.g.
    Anybody knows other solution for this problem?
    Thanks for read

    You could check your approach against this article: http://support.apple.com/kb/HT4083.  If you are still having trouble you could try an app that will send it wirelessly, such as PhotoSync.

  • Copy a file from server to the client - URLConnection to a Portal page

    Hello:
    I have an application running on the client side. When the app startup it must open a file which is at the server side, to be more specific, the file is at KM content of the portal.
    I try to read it with URLConnection to copy the file from the server to the client, the app will do it, but "Server returned HTTP response code: 401 for URL:"
    If you copy&paste the url's file directly on the browser (http://host:port/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/ImagenesIM/file.txt) a login popup (look and feel windows) is display. After entering the user and psw the file is open without problem.
    Any idea what can I use or how do it ?.
    I think that probably I have to move the app to a was directory instead of portal directory.
    The app is execute via *.jnlp with a link at a portal page.
    Thanks a lot for your time.

    Javier,
    401 means authentication error, i.e. your application is not authenticated to KM.
    What you can do? Actually, it depends. Check current cookies in your application, probably there are SSO coockie or J2EE authentication cookie. You may try to set this cookies in URLConnection (via addHeader). Otherwise you have to supply authentication creadentials to URLConnection (also via addHeader, most probably, via Basic HTTP authentication scheme).
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • I had a system crash(with Vista).I cannot start up windows on that drive.I have Win 7 on a new drive.I can access the files on the old drive to copy them.I would like to know how to find and copy the bookmarks from Firefox on the old drive and copy to the

    Hi:
    I had a system crash and I cannot start windows (Vista)on it.I have a new drive running Win 7.How do I copy the files from the old drive's files to the new?The Bookmark files that is.
    Thanks.Any help is appreciated.
    Shaun

    This could help.
    http://support.mozilla.com/en-US/kb/Backing+up+your+information
    Basically, you have to copy your profile from the old hdd to the new one.

  • How to copy a file from one folder to another folder in Linux

    Hello everyone,
    Oracle forms 11g 11.1.2.0.0
    OS: Oracle Linux
    We use webutil to upload files to the application server from the client machine, and stores them in a folder named JOB_DOCS on the application server (This folder is created as a databse directory too). File types are JPEG, GIF, PDF, TXT, BMP, DOC, XLS etc...
    At a later stage when the user tries to view the uploaded documents, this was not getting displayed on the screen
    on our windows server, when the user clicks on the print button we copy the file from the JOB_DOCS folder to the forms\java folder using the below command
    HOST('COPY ' ||d:\JOB_DOCS\test.pdf||' '||'c:\oracle\middleware\as\forms\java\test.pdf ,NO_SCREEN);
    once the file is under the forms\java folder then it is getting displayed on the screen to print or save, and later we remove the file from forms\java folder.
    But my problem here is, recently we have installed our application on Oracle Linux server, and we have JOB_DOCS folder there, and the users can upload files to this folder also. How can we copy the file test.pdf from JOB_DOCS to forms/java in linux?
    And what could be the reson for the document cannot be accessed from the folder where it is saved? We tried giving folder permissions, adding the folder to PATH variable etc.

    For copying and moving directories you can use the cp and mv commands just like you use them with files. Yeah, I know. If you've already tried to copy a directory with cp, you've probably noticed that cp just complains at you. Probably it says something like cp: omitting directory yadda yadda. You see, the cp command wants you to use the -r option if you want to copy a directory with its contents. The -r means "copy recursively":
    $ cp -r dir1 dir2
    The above creates a directory named dir2 whose contents will be identical to dir1. However, if dir2 already exists, nothing will be overwritten: the directory dir1 will be copied into the dir2 directory under the name dir2/dir1.
    When renaming directories, you use the mv command exactly the same way as with files:
    $ mv dir1 dir2
    When dealing with directories, mv works a bit like cp does. If dir2 doesn't exist, the above will rename dir1 to dir2, but if dir2 exists, the directory dir1 will be moved into the dir2 directory under the name dir2/dir1.
    ref http://www.tuxfiles.org/linuxhelp/dirman.html

  • Restoring my mac book pro after copying the files off via target disk

    Hi guys any help would be great.
    I had a problem with my hard drive in my early MBP, after seeing an apple genius, who said it was mostly likely a software issue and wiping the disk and reinstalling everything shoudl fix it.
    So as i didnt have an up to date time machine back up, i used the target disk utility to copy the files from the drive over onto another mac (actualy on a networked harddrive)
    no i have completed a wipe, and reinstalled the operating system (snow leapeard as thats the last disc i had - MBP was on Lion prior to the issues)
    now i want to restore all my files from before.
    what is the best way to do this?
    can i just drag and drop each file from the networked hard drive back into the coresponding ones on my MBP?
    thanks

    Only your users files inside music, pictures, movies documents etc folders.
    Nothing in Library, nor Applcations, you do that you hose the account and the apps won't work anyway, at least most of them.
    or i will have to reinstall the aplications but i tunes and so on will be able to find the files?
    yes and reinport music into iTunes so it goes into the new itunes library file, ditto with iPhoto Library (old) righ click and "show package contents" and import the Originals folder contents into new iPhoto library.
    support files have paths in their files that go to the path on the origanl system, you changed that so the paths are off, so you import the original files again.

Maybe you are looking for

  • How to share a Logic Pro project

    Hello, I'm looking a way to share a Logic Pro project since MobileMe doesn't exist any more ? Thx regards Pascal

  • Command button in the selection facet of a table

    hi, i am implementing a search page,where filed to enter search criteria is in main page, when a user enters enters search criteria and clicks on a command button search results are displayed in the popup. again if the user selects a particular recor

  • Property Configuration iView Exception!

    Hi Everybody, We are facing this exception: Portal Runtime Error An exception occurred while processing a request for : iView : pcd:portal_content/administrator/system_admin/system_admin_role/com.sap.portal.system_admin_ws/com.sap.portal.system_confi

  • How show / Hide DVT : barGraph programatically.

    Hi All , I have requirement , The page have two graph , Based on user action one bar graph should display and another bar graph should hide.

  • Failed to stop two components in application server

    my operating system is hp-ux 11.1,when iI use the command :opmnctl stopall to stop all compenents in middle-tier 904,but there are two components can not be stopped because of timeout. how should i do any help will be appreciated.