Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package weather;
- import examples.IOUtil;
- import java.io.BufferedWriter;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStreamWriter;
- import java.io.Writer;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import org.apache.commons.net.telnet.TelnetClient;
- public class Weather {
- public Weather() {
- }
- public static void main(String[] args) throws UnknownHostException, IOException {
- int port = 3000;
- InetAddress host = InetAddress.getByName("rainmaker.wunderground.com");
- TelnetClient tc = new TelnetClient();
- tc.connect(host, port);
- FileOutputStream weatherLog = new FileOutputStream("weather.log");
- IOUtil.readWrite(tc.getInputStream(), tc.getOutputStream(), System.in, System.out);
- IOUtil.readWrite(tc.getInputStream(), tc.getOutputStream(), System.in, weatherLog);
- Writer writer = new BufferedWriter(new OutputStreamWriter(weatherLog, "utf-8"));
- writer.flush();
- writer.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment