<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816174</guid>
        <pubDate>Wed, 04 Apr 2001 07:22:00 +0000</pubDate>
        <title>Файлы с Internet</title>
        <link>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816174</link>
        <description><![CDATA[lamo: ps:<br>ессно после "GET /NonCGI/posticon.gif HTTP/1.0"<br>нужно "\n\n" (см. rfc по http протоколу).<br>а как тип узнать, то это в Content-Type<br>увидиш в http заголовке ответа<br>(см. rfc по http протоколу) :<br>Content-Type: image/jpeg,<br>Content-Type: image/gif, and etc ...]]></description>
        <author>lamo</author>
        <category>Java</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816173</guid>
        <pubDate>Wed, 04 Apr 2001 07:18:00 +0000</pubDate>
        <title>Файлы с Internet</title>
        <link>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816173</link>
        <description><![CDATA[lamo: int i_buf = 0;<br>Socket sock_s;<br>InputStream st_inp;<br>OutputStream st_out;<br>try<br>{<br> sock_s = new Socket(www.sources.ru,80);<br> st_inp = sock_s.getInputStream();<br> st_out = sock_s.getOutputStream();<br> st_out.write(new String("GET /NonCGI/posticon.gif HTTP/1.0").getBytes());<br> FileOutputStream fs_out = new FileOutputStream("nfile.graf");<br> while ((i_buf = st_inp.read()) != -1)<br> {<br>  fs_out.write(i_buf); // http заголовок сам отпарси.<br> }<br> fs_out.close();<br> st_inp.close();<br> st_out.close();<br> sock_s.close();<br>}<br>catch(UnknownHostException ex)<br>{<br> System.out.println("Unknown host.");<br>}<br>catch(Exception ioe)<br>{<br> System.out.println(ioe.toString());<br>}]]></description>
        <author>lamo</author>
        <category>Java</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816172</guid>
        <pubDate>Wed, 04 Apr 2001 00:07:00 +0000</pubDate>
        <title>Файлы с Internet</title>
        <link>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816172</link>
        <description><![CDATA[Andrew: Спасибо за пример, но мне нужно, чтобы не текстовый файл качался, а графический.<br>Может кто знает.]]></description>
        <author>Andrew</author>
        <category>Java</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816171</guid>
        <pubDate>Thu, 29 Mar 2001 06:16:00 +0000</pubDate>
        <title>Файлы с Internet</title>
        <link>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816171</link>
        <description><![CDATA[purpe: вот так можно взять файлик с курсом доллара с сервера РосБизнесКонсалтинга:<br>URL homeRBC = null;<br>DataInputStream dis = null;<br>String full = new String();<br>boolean cont2 = false;<br>try {<br>homeRBC = new URL("http://www.rbc.ru/out/801.csv");<br>dis = new DataInputStream(homeRBC.openStream());<br>String line = dis.readLine();<br>while(line != null) {<br>full += line + "\n";<br>line = dis.readLine();<br>}<br>cont2 = true;<br>} catch(IOException e) {<br>System.out.println("Error for connection to RBC ...");<br>}<br>if(cont2==true) {<br>String cbr = toUnicode(full);<br>}<br>После этого в переменной cbr будет храниться содержимое файлика 801.csv<br>функция toUnicode выглядит следующим образом:<br>public static String toUnicode(String str) throws IOException {<br>try {<br>String charset="windows-1251";<br>byte[] buf = new byte[str.length()];<br>str.getBytes(0, str.length(), buf, 0);<br>return new String(buf);<br>} catch(Exception e) {<br>return "Error toUnicode";<br>}<br>}<br><br>как записывать файл - сразу не вспомню, надо поискать ...]]></description>
        <author>purpe</author>
        <category>Java</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816170</guid>
        <pubDate>Thu, 29 Mar 2001 00:52:00 +0000</pubDate>
        <title>Файлы с Internet</title>
        <link>https://forum.sources.ru/index.php?showtopic=109799&amp;view=findpost&amp;p=816170</link>
        <description><![CDATA[Andrew: Пожайлуста помогите!<br>Есть url по нему нужно скачать файл к себе на диск в указаную папку(т.е. чтобы я сам путь писак куда качать). Как это можно реализовать?<br>P.S. И если можно то как зделать проверку, какого типа этот файл.]]></description>
        <author>Andrew</author>
        <category>Java</category>
      </item>
	
      </channel>
      </rss>
	