File input stream conflict from windows to linux?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akoymakoy
    New Member
    • Oct 2006
    • 42

    File input stream conflict from windows to linux?

    InputStream in=null;
    OutputStream out = null;
    String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

    String src = c:\samplepic.jp g

    in = new FileInputStream (src);
    fileName="/packages.gif";

    out = new FileOutputStrea m(webDirectory+ fileName);
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    }
    in.close();
    out.close();


    This is a part of my method

    it is a web application where in i browse for the new picture and replace it with the existing one located on "webDirecto ry" ...
    when i try it on my pc where the "webDirecto ry" is:
    C:\Program Files\Apache Software Foundation\Tomc at 5.5\webapps\LaC oronaHotel

    it works


    but right after i upload it on my hosting where it is hosted in a linux computer it doesnt work.. i get no error logs, it just wont work any ideas?? anything i might have missed?
    is it possible to change a file from a windows to linux?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Just make sure those pathnames are correct and that you have read and write
    permission in the source and destination. Linux doesn't do anything mysterious
    to those files nor to their content.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      ... and use relative file names. Read about ServletContext.

      Comment

      • akoymakoy
        New Member
        • Oct 2006
        • 42

        #4
        well i have 2 kinds of process one is that of the picture changing and the other is .txt

        the .txt file is changing properly while that of the picture is not..

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by akoymakoy
          well i have 2 kinds of process one is that of the picture changing and the other is .txt

          the .txt file is changing properly while that of the picture is not..
          Well, then the path to your .txt file seems to be correct while the path to your
          .jpg file happens to be incorrect.

          kind regards,

          Jos

          Comment

          • akoymakoy
            New Member
            • Oct 2006
            • 42

            #6
            InputStream in=null;
            OutputStream out = null;
            String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

            String src = c:\samplepic.jp g

            in = new FileInputStream (src);
            fileName="/packages.gif";

            out = new FileOutputStrea m(webDirectory+ fileName);
            while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
            }
            in.close();
            out.close();


            this is my code

            the error log tells me that fileNotFound exception on the variable "src".
            i dont get it since this file is something i used from this page:
            <input type="file"name ="src">
            when i use it on a windows based server it runs well but on the linux server it doesnt .

            is there a particular something that i miss? or that i dont know of on linux?

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by akoymakoy
              InputStream in=null;
              OutputStream out = null;
              String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

              String src = c:\samplepic.jp g

              in = new FileInputStream (src);
              fileName="/packages.gif";

              out = new FileOutputStrea m(webDirectory+ fileName);
              while ((len = in.read(buf)) > 0) {
              out.write(buf, 0, len);
              }
              in.close();
              out.close();


              this is my code

              the error log tells me that fileNotFound exception on the variable "src".
              i dont get it since this file is something i used from this page:
              <input type="file"name ="src">
              when i use it on a windows based server it runs well but on the linux server it doesnt .

              is there a particular something that i miss? or that i dont know of on linux?
              If src points to c:\samplepic.jp g then you surely can't expect it to work on linux.

              Comment

              • akoymakoy
                New Member
                • Oct 2006
                • 42

                #8
                is there a way to copy this file to the linux directory?

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by akoymakoy
                  is there a way to copy this file to the linux directory?
                  How about reading about how to use relative file path names like I suggested above first?

                  Comment

                  • akoymakoy
                    New Member
                    • Oct 2006
                    • 42

                    #10
                    Originally posted by r035198x
                    How about reading about how to use relative file path names like I suggested above first?

                    since the programs aim is to change a particular picture:

                    i dont know how i will implement relative path names if i am to select a picture file from the windows directory. where do i put it?
                    note that the app is running on the linux server.

                    Comment

                    Working...