简体   繁体   中英

How can I work with a .csv file using Java Spring Resttample?

I have a small problem concerning using a .csv file with the Resttemplate from java spring. It looks somehow like:

URL url = URL url = new URL("http://data.wien.gv.at/daten/geo?service=WFS&version=1.0.0&request=GetFeature&typeName=ogdwien:GEONAMENSVERZOGD&outputFormat=CSV");
RestTemplate restTemplate = new RestTemplate();

Late on I want to use the getForObject() Method by the restTemplate, but I down't know how to proceed since I can't find matching paramteres anywehere on the internet.

Thank you for your help!

First, you'll need a CSV parsing library such as SuperCSV or OpenCSV.

Second you can add a HttpMessageConverter to Spring to convert csv input to java objects. http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/converter/HttpMessageConverter.html

Having that set up, you'll be able to getForObject and get java objects directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM