Hi

Apologies if I am not supposed to POST this here. If somebody has already
done this please help me to do this.

I am trying to post rdf files into Virtuoso using HttpURLconnection in Java.
I have my instance of virtuoso up and running.

Using curl, this is how I did it earlier from command line.

curl -i -T bio2rdfdemo.rdf
http://gf18.ucs.indiana.edu:8890/DAV/home/schalla/rdf_sink/bio2rdfdemo.rdf-u
"username:password"

Now I am trying to do it in Java

String rdfcontent = "";
String response = "";
HttpURLConnection con = null;
try{
   File rdffile = new
File("C:\\Users\\LaxmiR\\Desktop\\ORECHEM\\ATOMGRDDL\\bio2rdfdemo.rdf");
  BufferedReader input =  new BufferedReader(new FileReader(rdffile));
  String line =null;
  while((line = input.readLine())!=null){
line = line +"\n";
rdfcontent = rdfcontent + line;
  }
  input.close();
  String username = "username";
  String password = "password";
  Authenticator.setDefault(new SimpleAuthenticator(username,password));
  con = (HttpURLConnection) new URL("
http://gf18.ucs.indiana.edu:8890/DAV/home/schalla/rdf_sink
").openConnection();
  con.setRequestMethod("POST");
  con.setDoOutput(true);
  OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
  out.write(rdfcontent);
  out.close();
  InputStream in = con.getInputStream();
  BufferedReader rd = new BufferedReader(new InputStreamReader(in));
  String line2;

 while((line2 = rd.readLine()) != null) {
       response = response + line2;
        //response.append('\r');
  }
  rd.close();

}catch (IOException e) {
e.printStackTrace();
}finally{
con.disconnect();
}
System.out.println(response);

0) Am I using the correct URL to post into rdf_sink ??
1) Is Authenticator required for virtuoso ?
2) how do I do curl -u in Java, i.e. provide username and password.
3) I am actually Posting the string from a file, how do I *directly POST the
file*

Thanks in advance

Regards


-- 
Sashikiran Challa

Reply via email to