Results 1 to 10 of 10
  1. #1
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default Accessing local file from server side using Java Application

    Hi

    I want to write a code that will access the local file from the server side using Java Application. I have my java code running as a server and I want to access the file located in the local system which is connected with the server where my java code is running.

    Thanks

    Sachin

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What kind of client/server application do you have?
    Is it a web application or are you serving a Java application via webstart e.t.c?
    Why did you post this in the databases forum?

  3. #3
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Hi r035198x

    I know I did that by mistake putting this post under database. But I was told that it is related with ODBC so i thought may be this is the best tittle. I have a java program running on my company's server. It is not a client-server model but just a simple java program that has to run 24x7 coz it extracts data from the website. Now i have access a file located in the local system which is connected with this server.

    Thanks

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    How is the client computer connected to the server? Are the two computers on the same network and are able to communicate with each other say, via ssh, ftp?

  5. #5
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    The two computers are on same network I guess. I can let you know that once i talk to the system admin. But can I coonect to that system by using the IP Address of the system and access those files.

    Thanks

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Copying a file over the network then? The code has been written lots of times.
    Google will point to an assortment.

  7. #7
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    The thing is that I have to establish a connection with that machine and for that I have written:

    url = "jdbc:odbc:10.1.0.207";

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    conn = DriverManager.getConnection (url, "administrator", "meri");

    10.1.0.207 being the IP address of that machine.

    but it gives me null pointer exception.

    I really appreciate your help. Thanks

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Why are you using JDBC at all?
    You are not trying to get data from the database, you are just trying to copy a file over the network, right?

  9. #9
    ersachinjain is offline Member
    Join Date
    Aug 2009
    Posts
    51
    Rep Power
    0

    Default

    Yes you are right.

    I have made slight changes to my code:

    url2 = new URL("http","10.1.0.120","C:/password.txt");

    URLC = url2.openConnection();
    filein = URLC.getInputStream();

    This is what i am using. But it is giving me an exception filenotfound even though the file is there.

  10. #10
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Just copy the file as an output stream using a Socket/BufferedOutputStream pair.
    Just google "Copying a file over the network Java" and you should get countless examples.

Similar Threads

  1. updating server side file using java bean
    By tskarthic in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-30-2009, 02:53 PM
  2. How to open a file located in server from client side
    By Malathi in forum Web Frameworks
    Replies: 4
    Last Post: 04-20-2009, 09:10 PM
  3. Replies: 2
    Last Post: 04-06-2009, 05:52 PM
  4. Replies: 1
    Last Post: 03-27-2009, 10:18 AM
  5. Replies: 2
    Last Post: 10-05-2008, 06:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •