cancel
Showing results for 
Search instead for 
Did you mean: 

Read/Write a file from local directory

Former Member
0 Kudos

Hi All,

I am trying to access a text file from the local directory.

The code is,

FileReader fr = new FileReader("c:/temp/1.txt");

This code raises an exception:

c:\temp\1.txt (The system cannot find the file specified)

What is wrong in this code?

How do i read a file then?

Thanks

Thruna

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Turuna,

Does "c:\temp\1.txt" really exist on the SERVER where you are running your code?

Best regards, Maksim Rashchynski.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Tiruna,

at first: This example is just for a demo case. Don't use it for real use cases. You won't know the path on the server, where you want to get your file from. Use the URL Generator Service: http://help.sap.com/saphelp_nw2004s/helpdata/en/9e/a073001903c9419592b14c2aa63669/frameset.htm

Back to your issue: If your server is a windows machine, build the string in this way: "C:
temp
1.txt"

Kind Regards

Stefanie

Former Member
0 Kudos

Hi,

While running your project on server it always check to server path. It doesn't check on client machine. So please verify this file is avilable on server.

Kind Regards,

S.Saravanan.