You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by tina sani <ti...@gmail.com> on 2016/06/18 23:40:32 UTC

creating rdf file on disk using java

Hello all.
How can I create an RDF file using Jena and then save some data like
student name. address etc?

Re: creating rdf file on disk using java

Posted by Dave Reynolds <da...@gmail.com>.
Another, hopefully remote, possibility might be a failure to close the 
output stream (if the data is smaller than the output buffer).

Dave

On 20/06/16 13:29, John A. Fereira wrote:
> Yes. Since the rdf file is being created but is empty, that implies that the problem lies in adding statements to the model.  There are lots of examples one can find by searching for \u201cjena write rdf example\u201d, including an example in the Jena release:
>
> https://github.com/apache/jena/blob/master/jena-core/src-examples/jena/examples/rdf/Tutorial04.java
>
>
>
>
>
> On 6/20/16, 2:17 AM, "Lorenz B." <bu...@informatik.uni-leipzig.de> wrote:
>
>> We can not help you without seeing the code. You already call
>> model.save() which writes the model as RDF to disk. If your file is
>> empty, something goes wrong with your code that adds triples to the model.
>>
>> Lorenz
>>
>>> I do not have currently code in hand but my scenario is that I have created
>>> an ontology for university library having information about book details,
>>> authors, employee working in library. I will read the file in Jena code
>>> later.
>>>
>>> But I want to keep track of each student login to the system i-e what type
>>> of book they search usually, at what time he visits the system so I need a
>>> file holding just name and her Id to uniquely identify her.
>>> I have created a file using Java (as mentioned in previous email) but dont
>>> know how to store student login information in it?
>>>
>>> The student does not have to register first so need for database, just keep
>>> track of her name/ID to find their preference?
>>>
>>> Thank you
>>>
>>>
>>> On Sun, Jun 19, 2016 at 11:09 AM, A. Soroka <aj...@virginia.edu> wrote:
>>>
>>>> Can you show some actual example code that you are trying to use?
>>>> Otherwise it's difficult to say what is not right.
>>>>
>>>> ---
>>>> A. Soroka
>>>> The University of Virginia Library
>>>>
>>>>> On Jun 19, 2016, at 10:57 AM, tina sani <ti...@gmail.com> wrote:
>>>>>
>>>>> Actually I have already read this documentation but I did not find what I
>>>>> am looking for exactly. In documentation, it includes something like
>>>>> this :model.write(System.out);
>>>>> which only writes a model to a file.
>>>>>
>>>>> What I needed is to create an rdf file locally on disk using Jena code
>>>> and
>>>>> then store some users data inside that file. Like
>>>>> FileOutputStream fout=new FileOutputStream(
>>>>>   "C:\\desktop//tina.rdf");
>>>>>   model.write(fout);
>>>>> The file on my desktop is actually created but it is an empty file but I
>>>>> want some input from users and store it in this file which currently I am
>>>>> not sure how to do it.
>>>>>
>>>>> Thank you
>>>>>
>>>>> <
>>>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>>>> Virus-free.
>>>>> www.avast.com
>>>>> <
>>>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>>>> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>>
>>>>> On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:
>>>>>
>>>>>> Please start with the documentation provided for exactly this purpose:
>>>>>>
>>>>>> https://jena.apache.org/tutorials/rdf_api.html
>>>>>> https://jena.apache.org/getting_started/
>>>>>>
>>>>>> ---
>>>>>> A. Soroka
>>>>>> The University of Virginia Library
>>>>>>
>>>>>>> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com>
>>>> wrote:
>>>>>>> Hello all.
>>>>>>> How can I create an RDF file using Jena and then save some data like
>>>>>>> student name. address etc?
>>>>>>
>>>>
>> --
>> Lorenz B�hmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>


Re: creating rdf file on disk using java

Posted by "John A. Fereira" <ja...@cornell.edu>.
Yes. Since the rdf file is being created but is empty, that implies that the problem lies in adding statements to the model.  There are lots of examples one can find by searching for “jena write rdf example”, including an example in the Jena release: 

https://github.com/apache/jena/blob/master/jena-core/src-examples/jena/examples/rdf/Tutorial04.java





On 6/20/16, 2:17 AM, "Lorenz B." <bu...@informatik.uni-leipzig.de> wrote:

>We can not help you without seeing the code. You already call
>model.save() which writes the model as RDF to disk. If your file is
>empty, something goes wrong with your code that adds triples to the model.
>
>Lorenz
>
>> I do not have currently code in hand but my scenario is that I have created
>> an ontology for university library having information about book details,
>> authors, employee working in library. I will read the file in Jena code
>> later.
>>
>> But I want to keep track of each student login to the system i-e what type
>> of book they search usually, at what time he visits the system so I need a
>> file holding just name and her Id to uniquely identify her.
>> I have created a file using Java (as mentioned in previous email) but dont
>> know how to store student login information in it?
>>
>> The student does not have to register first so need for database, just keep
>> track of her name/ID to find their preference?
>>
>> Thank you
>>
>>
>> On Sun, Jun 19, 2016 at 11:09 AM, A. Soroka <aj...@virginia.edu> wrote:
>>
>>> Can you show some actual example code that you are trying to use?
>>> Otherwise it's difficult to say what is not right.
>>>
>>> ---
>>> A. Soroka
>>> The University of Virginia Library
>>>
>>>> On Jun 19, 2016, at 10:57 AM, tina sani <ti...@gmail.com> wrote:
>>>>
>>>> Actually I have already read this documentation but I did not find what I
>>>> am looking for exactly. In documentation, it includes something like
>>>> this :model.write(System.out);
>>>> which only writes a model to a file.
>>>>
>>>> What I needed is to create an rdf file locally on disk using Jena code
>>> and
>>>> then store some users data inside that file. Like
>>>> FileOutputStream fout=new FileOutputStream(
>>>>  "C:\\desktop//tina.rdf");
>>>>  model.write(fout);
>>>> The file on my desktop is actually created but it is an empty file but I
>>>> want some input from users and store it in this file which currently I am
>>>> not sure how to do it.
>>>>
>>>> Thank you
>>>>
>>>> <
>>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>>> Virus-free.
>>>> www.avast.com
>>>> <
>>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>>> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>
>>>> On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:
>>>>
>>>>> Please start with the documentation provided for exactly this purpose:
>>>>>
>>>>> https://jena.apache.org/tutorials/rdf_api.html
>>>>> https://jena.apache.org/getting_started/
>>>>>
>>>>> ---
>>>>> A. Soroka
>>>>> The University of Virginia Library
>>>>>
>>>>>> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com>
>>> wrote:
>>>>>> Hello all.
>>>>>> How can I create an RDF file using Jena and then save some data like
>>>>>> student name. address etc?
>>>>>
>>>
>-- 
>Lorenz Bühmann
>AKSW group, University of Leipzig
>Group: http://aksw.org - semantic web research center
>

Re: creating rdf file on disk using java

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
We can not help you without seeing the code. You already call
model.save() which writes the model as RDF to disk. If your file is
empty, something goes wrong with your code that adds triples to the model.

Lorenz

> I do not have currently code in hand but my scenario is that I have created
> an ontology for university library having information about book details,
> authors, employee working in library. I will read the file in Jena code
> later.
>
> But I want to keep track of each student login to the system i-e what type
> of book they search usually, at what time he visits the system so I need a
> file holding just name and her Id to uniquely identify her.
> I have created a file using Java (as mentioned in previous email) but dont
> know how to store student login information in it?
>
> The student does not have to register first so need for database, just keep
> track of her name/ID to find their preference?
>
> Thank you
>
>
> On Sun, Jun 19, 2016 at 11:09 AM, A. Soroka <aj...@virginia.edu> wrote:
>
>> Can you show some actual example code that you are trying to use?
>> Otherwise it's difficult to say what is not right.
>>
>> ---
>> A. Soroka
>> The University of Virginia Library
>>
>>> On Jun 19, 2016, at 10:57 AM, tina sani <ti...@gmail.com> wrote:
>>>
>>> Actually I have already read this documentation but I did not find what I
>>> am looking for exactly. In documentation, it includes something like
>>> this :model.write(System.out);
>>> which only writes a model to a file.
>>>
>>> What I needed is to create an rdf file locally on disk using Jena code
>> and
>>> then store some users data inside that file. Like
>>> FileOutputStream fout=new FileOutputStream(
>>>  "C:\\desktop//tina.rdf");
>>>  model.write(fout);
>>> The file on my desktop is actually created but it is an empty file but I
>>> want some input from users and store it in this file which currently I am
>>> not sure how to do it.
>>>
>>> Thank you
>>>
>>> <
>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>> Virus-free.
>>> www.avast.com
>>> <
>> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
>>> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>> On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:
>>>
>>>> Please start with the documentation provided for exactly this purpose:
>>>>
>>>> https://jena.apache.org/tutorials/rdf_api.html
>>>> https://jena.apache.org/getting_started/
>>>>
>>>> ---
>>>> A. Soroka
>>>> The University of Virginia Library
>>>>
>>>>> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com>
>> wrote:
>>>>> Hello all.
>>>>> How can I create an RDF file using Jena and then save some data like
>>>>> student name. address etc?
>>>>
>>
-- 
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Re: creating rdf file on disk using java

Posted by tina sani <ti...@gmail.com>.
I do not have currently code in hand but my scenario is that I have created
an ontology for university library having information about book details,
authors, employee working in library. I will read the file in Jena code
later.

But I want to keep track of each student login to the system i-e what type
of book they search usually, at what time he visits the system so I need a
file holding just name and her Id to uniquely identify her.
I have created a file using Java (as mentioned in previous email) but dont
know how to store student login information in it?

The student does not have to register first so need for database, just keep
track of her name/ID to find their preference?

Thank you


On Sun, Jun 19, 2016 at 11:09 AM, A. Soroka <aj...@virginia.edu> wrote:

> Can you show some actual example code that you are trying to use?
> Otherwise it's difficult to say what is not right.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Jun 19, 2016, at 10:57 AM, tina sani <ti...@gmail.com> wrote:
> >
> > Actually I have already read this documentation but I did not find what I
> > am looking for exactly. In documentation, it includes something like
> > this :model.write(System.out);
> > which only writes a model to a file.
> >
> > What I needed is to create an rdf file locally on disk using Jena code
> and
> > then store some users data inside that file. Like
> > FileOutputStream fout=new FileOutputStream(
> >  "C:\\desktop//tina.rdf");
> >  model.write(fout);
> > The file on my desktop is actually created but it is an empty file but I
> > want some input from users and store it in this file which currently I am
> > not sure how to do it.
> >
> > Thank you
> >
> > <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> > Virus-free.
> > www.avast.com
> > <
> https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
> >
> > <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:
> >
> >> Please start with the documentation provided for exactly this purpose:
> >>
> >> https://jena.apache.org/tutorials/rdf_api.html
> >> https://jena.apache.org/getting_started/
> >>
> >> ---
> >> A. Soroka
> >> The University of Virginia Library
> >>
> >>> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com>
> wrote:
> >>>
> >>> Hello all.
> >>> How can I create an RDF file using Jena and then save some data like
> >>> student name. address etc?
> >>
> >>
>
>

Re: creating rdf file on disk using java

Posted by "A. Soroka" <aj...@virginia.edu>.
Can you show some actual example code that you are trying to use? Otherwise it's difficult to say what is not right.

---
A. Soroka
The University of Virginia Library

> On Jun 19, 2016, at 10:57 AM, tina sani <ti...@gmail.com> wrote:
> 
> Actually I have already read this documentation but I did not find what I
> am looking for exactly. In documentation, it includes something like
> this :model.write(System.out);
> which only writes a model to a file.
> 
> What I needed is to create an rdf file locally on disk using Jena code and
> then store some users data inside that file. Like
> FileOutputStream fout=new FileOutputStream(
>  "C:\\desktop//tina.rdf");
>  model.write(fout);
> The file on my desktop is actually created but it is an empty file but I
> want some input from users and store it in this file which currently I am
> not sure how to do it.
> 
> Thank you
> 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> 
> On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:
> 
>> Please start with the documentation provided for exactly this purpose:
>> 
>> https://jena.apache.org/tutorials/rdf_api.html
>> https://jena.apache.org/getting_started/
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com> wrote:
>>> 
>>> Hello all.
>>> How can I create an RDF file using Jena and then save some data like
>>> student name. address etc?
>> 
>> 


Re: creating rdf file on disk using java

Posted by tina sani <ti...@gmail.com>.
Actually I have already read this documentation but I did not find what I
am looking for exactly. In documentation, it includes something like
this :model.write(System.out);
which only writes a model to a file.

What I needed is to create an rdf file locally on disk using Jena code and
then store some users data inside that file. Like
FileOutputStream fout=new FileOutputStream(
  "C:\\desktop//tina.rdf");
  model.write(fout);
The file on my desktop is actually created but it is an empty file but I
want some input from users and store it in this file which currently I am
not sure how to do it.

Thank you

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sun, Jun 19, 2016 at 7:44 AM, A. Soroka <aj...@virginia.edu> wrote:

> Please start with the documentation provided for exactly this purpose:
>
> https://jena.apache.org/tutorials/rdf_api.html
> https://jena.apache.org/getting_started/
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com> wrote:
> >
> > Hello all.
> > How can I create an RDF file using Jena and then save some data like
> > student name. address etc?
>
>

Re: creating rdf file on disk using java

Posted by "A. Soroka" <aj...@virginia.edu>.
Please start with the documentation provided for exactly this purpose:

https://jena.apache.org/tutorials/rdf_api.html
https://jena.apache.org/getting_started/

---
A. Soroka
The University of Virginia Library

> On Jun 19, 2016, at 12:40 AM, tina sani <ti...@gmail.com> wrote:
> 
> Hello all.
> How can I create an RDF file using Jena and then save some data like
> student name. address etc?