Hi all,
I want to access the COSMIC biomart using smart services and Java. Here is
my code.


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;


public class accessDB {

    public static void saveDbData(String xmlName) throws Exception {


        try {
            URL url = new URL("http://www.biomart.org/martservice";);

            String fileContents = readFileAsString(xmlName);

            URLConnection urlc = url.openConnection();

            urlc.setDoOutput(true);

            urlc.setDoInput(true);

            PrintWriter pw = new PrintWriter(urlc.getOutputStream());
            pw.write(fileContents);

            pw.close();

            BufferedReader in = new BufferedReader(new
InputStreamReader(urlc.getInputStream()));

            String inputLine;

            while ((inputLine = in.readLine()) != null) {
                System.out.println(inputLine);
            }

            in.close();



        } catch (Exception e) {

        }
    }

    private static String readFileAsString(String filePath)
            throws java.io.IOException {
        StringBuilder fileData = new StringBuilder(1000);
        BufferedReader reader = new BufferedReader(
                new FileReader(filePath));
        char[] buf = new char[1024];
        int numRead = 0;
        while ((numRead = reader.read(buf)) != -1) {
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);
            buf = new char[1024];
        }
        reader.close();
        return fileData.toString();
    }
}

I used a XML file saved from the COSMIC Biomart site XML button. What could
be the problem. I think I am correct in thinking that if I POST the XML file
to the link it should work. What have I missed?
Thank you very much.

Regards,
Manjula

-- 

* <http://lk.linkedin.com/in/manjulapra>
*

*This communication (including any attachments) is intended for the use of
the intended recipient only and may contain information that is
confidential, privileged or legally protected. Any unauthorized use or
dissemination of this communication is strictly prohibited. If you have
received this communication in error, please immediately notify
[email protected] by return e-mail message and delete all copies of the
original communication. Thank you for your cooperation.*
_______________________________________________
Users mailing list
[email protected]
https://lists.biomart.org/mailman/listinfo/users

Reply via email to