//讀RDF的程序
import com.hp.hpl.jena.rdf.model.*;
import java.io.*;
public class read-rdf extends Object{
??? static final String inputFileName
?????????????????????????? = "i'm-rdf-file.rdf";
??? public static void main (Sring args[]){
??????? try? {
?????????? Model model = ModelFactory.createDefaultModel();
?????????? InputStream in = read-rdf.class
??????????????????????????????????? .getClassLoader()
??????????????????????????????????? .getResourceAsStream(inputFileName);
?????????? if (in == null) {
?????????????? throw new IllegalArgumentException(
?????????????????????? "file:" + inputFileName +"not found");
???????????? }
?????????? model.read(new InputStreamReader(in), "");
?????????? model.write(System.out);
??????? }
??? }
//寫RDF的程序
import com.hp.hpl.jena.rdf.model.*;
import java.io.*;
import com.hp.hpl.jena.xmloutput.*;
public static void main (String args[]){
??????? String programstype?? = "Jena";
??????? String writername???? = "xiaoxiao";
??????? String things???????? = "make the program";
??????? String task?????????? = writername + " " + things;
????
??????? try{
?????????? Model model = ModelFactory.createDefaultModel()??
?????????
?????????? Resource xiaoxiao
????????????? = model.createResource(programstype)
???????????????????? .addProperty(TASKS, task)
????????????????????????? model.createResource()
?????????????????????????????? .addProterty(WRITER, writername)
???????????? RDFWriter writer = model.getWriter();
???????????? writer.write(model,System.out, null);
??????????? }
}