cancel
Showing results for 
Search instead for 
Did you mean: 

Read a file from the local system

Former Member
0 Kudos

Hi,

Is it possible to read a file from the local system? If yes, how?

Please forward your suggestion..

Thanks,

RPN

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Is it possible to read a file from the local system? If yes, how?

Yes, Using file upload UI element , If you search you will get lot of material related with the same.

Regards

Ayyapparaj

Former Member
0 Kudos

Thanks a lot...

Is it possible to create a file in the hard coded path(say: C:/Adapter/log.txt here log.txt is the file to be created) in local system....

Thanks,

RPN

Former Member
0 Kudos

Thanks a lot...

Is it possible to create a file in the hard coded path(say: C:/Adapter/log.txt here log.txt is the file to be created) in local system....

Thanks,

RPN

former_member192434
Active Contributor
0 Kudos

yes..... see my post in your next question.

Former Member
0 Kudos

hi anup...

can you please post your answer in this forum. i face some technical problem in opening that forum....

thanks,

RPN

Former Member
0 Kudos

Hi,

Is it possible to create a file in the hard coded path(say: C:/Adapter/log.txt here log.txt is the file to be created) in local system....

Is it possible to create a file in the hard coded path(say: "C:/Adapter/log.txt ")?

Yes, but one thing you need to understand here is, this file will be created on the server system(WAS is installed) not on the client.

Regards

Ayyapparaj

Former Member
0 Kudos

No, it is not possible to refer in the code your local system.

C:\xyz indicates the server not the local system.

Regards,

Surya

Former Member
0 Kudos

Thanks gentlemen.....

can you please tell me the procedure to write a newly created file into a local system?

Thanks,

RPN

former_member192434
Active Contributor
0 Kudos

use this sample code........for writing file on local /remote system

public void onActionUploadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionUploadFile(ServerEvent)

String FileName = "temp";//wdContext.currentContextElement().getDirectory();

InputStream input = null;

int i=0;

FileIncreament();

try {

String directory =".
temp
webdynpro
web
local
yh1245_ftp"+

"
Components
com.yash.yh1245.Upload
"FileNamewdContext.currentContextElement().getCounter();

boolean sucsss = new File(directory).mkdir();

if(sucsss){

wdComponentAPI.getMessageManager().reportSuccess("Directory Created ");

File file = new File(directory"
"
wdContext.currentContextElement().getResourceURL().getResourceName().toString());

FileOutputStream fos = new FileOutputStream(file);

wdComponentAPI.getMessageManager().reportSuccess(file.getAbsolutePath());

FilePath = file.getAbsolutePath();

if(wdContext.currentContextElement().getResourceURL()!=null){

input = wdContext.currentContextElement().getResourceURL().read(false);

//wdComponentAPI.getMessageManager().reportSuccess("Resource is not null ");

while((i = input.read())!=-1){

fos.write(i);

}

}

fos.flush();

fos.close();

wdComponentAPI.getMessageManager().reportSuccess("File Uploaded on server directory ");

//wdComponentAPI.getMessageManager().reportSuccess("Created File Locaiton::"+file.getAbsolutePath());

//}

//Get the File Size

// IPrivateFTPUpload.IContextElement element = wdContext.currentContextElement();

// if (element.getResourceURL()!=null) {

// IWDResource resource = element.getResourceURL();

// element.getFileSize(this.getFileSize(resource));

// }

}

}catch(Exception e){

e.printStackTrace();

}

//@@end

}

Answers (2)

Answers (2)

Former Member
0 Kudos

thanks a lot to everyone...

former_member192434
Active Contributor
0 Kudos

You can read/write file using UI Elemement file upload and file download.

Thanks