Developer Forum [ All Topics | New Topic ]

Thread: c# code copied to java but not recognizing me

import java.net.URL; import java.io.*; import javax.net.ssl.HttpsURLConnection; public class ReadHttpsURL1 { public static void main(String[] args) throws Exception { String httpsURL = "https://www.rapnet.com/Rapnet/Prices/DownloadPriceSheet.aspx?PriceFormat=CSV2_ROUND"; URL myurl = new URL(httpsURL); HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); con.setDoInput(true); con.setDoOutput(true); final String postData = ("username=66919&password=ron7777"); final OutputStream outs = con.getOutputStream(); outs.write(postData.getBytes("ASCII")); outs.close(); final InputStream is = con.getInputStream(); final byte[] buffer = new byte[1024]; for (int count = 0; (count = is.read(buffer)) != -1;) { System.out.write(buffer, 0, count); } is.close(); InputStream ins = con.getInputStream(); InputStreamReader isr=new InputStreamReader(ins); BufferedReader in =new BufferedReader(isr); String inputLine; PrintStream out; try { out = new PrintStream (new BufferedOutputStream (new FileOutputStream("site.xml",false))); System.setOut(out); System.setErr(out); } catch(Exception e){} while ((inputLine = in.readLine()) != null) System.outs.println(inputLine); in.close(); } } This is the code in java that I wrote I copied the code that you wrote for c# but it is not recognizing me , any help please.

>> add a comment
amos and amnon
02/22/2010 05:25


1 Replies:

Hi will this help you? http://technet.rapaport.com/Info/RapLink/SampleCode/Java_Webrequest_Example.aspx

>> add a comment
Ahaliav Fox
2/23/2010 7:36:00 AM