You are on page 1of 2

import

import
import
import
import

oracle.forms.ui.*;
oracle.forms.properties.ID;
oracle.ewt.lwAWT.lwText.*;
java.awt.*;
java.io.*;

public class TextPJC extends VTextArea {


private static final ID READFILE = ID.registerProperty("readfile");
private static final ID WRITEFILE = ID.registerProperty("writefile");
private String filename=null;
public TextPJC() {
super();
}
public boolean setProperty(ID pid, Object value)
{
if(pid ==READFILE) {
try {
File inputFile = new File((String)value);
FileReader in = new FileReader(inputFile);
char c[] = new char[(int)inputFile.length()];
char c1[]= new char[(int)inputFile.length()];
in.read(c);
int j=0;
for (int i=0;i<inputFile.length();i++)
{
if((int)c[i]==13);
else
c1[j++]=c[i];
}
String str = String.copyValueOf(c1,0,j);
this.setContent(new LWTextArea(str));
in.close();
}
catch(Exception e) {System.out.println("Error in PJC " );e.printStackTrac
e();}
return true;
}
else if(pid==WRITEFILE) {
try {
File inputFile = new File((String)value);
FileWriter in = new FileWriter(inputFile);
LWTextArea lw = (LWTextArea)(this.getContent());
String text1 = lw.getText();
int length1 = text1.length();
char c[] = new char[(int)length1];
char c1[]= new char[(int)length1*2];
text1.getChars(0,length1,c,0);
int j=0;
String s1= System.getProperty("line.separator");
for(int i=0;i<length1;i++)
{
if ((int)c[i]==10)
{
s1.getChars(0,s1.length(),c1,j);
j=j+s1.length();
}
else
c1[j++]=c[i];

}
in.write(c1,0,j);
in.flush();
in.close();
}
catch(Exception e) {System.out.println("Error " );e.printStackTrace
();}
return true;
}
else
return super.setProperty(pid,value);
}
}

You might also like