문제

I am trying to write an application engine program which would generate an output file. My goal is to write this file by using the PeopleSoft function 'CreateJavaObject'. I tried this:

Local string &msg;
Local JavaObject &jFile, &writeFile;

&msg = "Hello World!";

&jFile = CreateJavaObject("java.IO.File", "c:\temp\log.txt");
&writeFile = CreateJavaObject("java.IO.BufferedWriter", &jFile);

&writeFile.writeFile(&msg);

When I run the application engine program, the program abends and the error is at the object java.IO.BufferedWriter which says incorrect argument passed.

Is there any way in peoplesoft where File I/O can be handled in using java functions.

도움이 되었습니까?

해결책

I have fixed the issue. Here is the code

Local JavaObject &jFile;
Local JavaObject &msg;
&msg = CreateJavaObject("java.lang.String", "Hello World!");

Local JavaObject &buf = &msg.getBytes();
Local number &byteCount = &buf.length;
&jFile = CreateJavaObject("java.io.FileOutputStream", "C:\Temp\java.txt", True);
&jFile.write(&buf, 0, &byteCount);
&jFile.close();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top