Writing to a file on webserver

Discussion in 'Java' started by stevesuts@gmail.com, Apr 28, 2005.

  1. Guest

    I have an EJB that passes a vector of data to another java class and
    that class writes that vector to a file. I can get this to run on my
    local server using WSAD. I can delete, create and write to this file.
    However, when I put it out on the server (AIX box) I can't get it to do
    anything of the sort. I will post my code:

    public void deleteFtpFile()
    {
    String AOSFILEPATH = null;
    String AOSFILENAME = null;
    EnvData evd = new EnvData();
    AOSFILEPATH = evd.getAosFtpFilePath();
    AOSFILENAME = evd.getAosFtpFileName();
    System.out.println("AOS FILE PATH IS : " + AOSFILEPATH );
    System.out.println("AOS FILE NAME IS : " + AOSFILENAME );
    String dirName = (AOSFILEPATH);
    String aosFileName = (AOSFILENAME);
    File aosFileDir = new File(dirName);
    File aosFile = new File(dirName, aosFileName);
    if(aosFile.exists())
    {
    aosFile.delete();
    System.out.println("File Has Been Deleted!!!!!!!!!!!!");
    }

    }


    public int writeToFile2(Vector aosData)
    {
    System.out.println("YOU ARE IN THE WRITE TO FILE FUNCTION");
    int returnCde = 0;
    String temp = null;
    FileWriter fw = null;
    PrintWriter fout = null;
    String AOSFILEPATH = null;
    String AOSFILENAME = null;
    EnvData evd = new EnvData();


    if (aosData ==null)
    {
    System.out.println("AOSDATA VECTOR NOT MAKING IT OVER TO HERE");
    }



    Iterator i = aosData.iterator();



    AOSFILEPATH = evd.getAosFtpFilePath();
    AOSFILENAME = evd.getAosFtpFileName();
    System.out.println("AOS FILE PATH IS : " + AOSFILEPATH );
    try
    {
    String dirName = (AOSFILEPATH);
    String aosFileName = (AOSFILENAME);
    File aosFileDir = new File(dirName);
    File aosFile = new File(dirName, aosFileName);
    if(!aosFileDir.exists())
    {
    System.out.println("TRYING TO CREATE THE directory");
    aosFileDir.mkdir();
    }
    else if(!aosFileDir.isDirectory())
    {
    System.out.println("The Directory does not exist");
    //return(1);
    }
    if(!aosFile.exists())
    {
    System.out.println("TRYING TO CREATE THE FILE");
    aosFile.createNewFile();
    }
    fw = new FileWriter(aosFile);
    fout = new PrintWriter(fw);

    while(i.hasNext())
    {
    System.out.println("Record Written to File");
    fout.println(i.next());
    }

    }
    catch (IOException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    finally
    {
    try
    {
    if (fout != null) fout.close();
    if (fw != null) fw.close();
    }
    catch (IOException ioe)
    {
    ioe.printStackTrace();
    }
    }



    return (returnCde);
    }


    Can anyone help me out?
     
    , Apr 28, 2005
    #1
    1. Advertising

  2. enrique Guest

    Are you sure it's not permission-related (JVM permission to write to
    the filesystem, or otherwise)?
     
    enrique, Apr 28, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. randall g
    Replies:
    2
    Views:
    7,521
    Rajesh.V
    Oct 27, 2003
  2. HNguyen
    Replies:
    4
    Views:
    2,439
    HNguyen
    Dec 21, 2004
  3. news.microsoft.com
    Replies:
    4
    Views:
    5,006
    =?Utf-8?B?Q2hpbm1heQ==?=
    Jan 10, 2005
  4. David Hubbard
    Replies:
    0
    Views:
    473
    David Hubbard
    Jan 24, 2006
  5. Replies:
    8
    Views:
    1,080
    Diez B. Roggisch
    Jan 4, 2010
Loading...

Share This Page