List of usage examples for org.apache.commons.net.nntp NNTPClient connect
public void connect(InetAddress host) throws SocketException, IOException
From source file:org.ossmeter.platform.communicationchannel.nntp.local.NntpUtil.java
public static NNTPClient connectToNntpServer(NntpNewsGroup newsgroup) { NNTPClient client = new NNTPClient(); client.setDefaultPort(newsgroup.getPort()); String serverUrl = newsgroup.getUrl().substring(0, newsgroup.getUrl().lastIndexOf("/")); try {//from ww w .j ava 2s . c om client.connect(serverUrl); if (newsgroup.getAuthenticationRequired()) { client.authenticate(newsgroup.getUsername(), newsgroup.getPassword()); } } catch (SocketException e) { // TODO Auto-generated catch block System.err.println("SocketException while connecting to NNTP server: '" + newsgroup.getUrl() + "': " + e.getMessage()); // System.exit(1); } catch (IOException e) { // TODO Auto-generated catch block System.err.println( "IOException while connecting to NNTP server: '" + newsgroup.getUrl() + "': " + e.getMessage()); // System.exit(1); } return client; }
From source file:org.ossmeter.platform.communicationchannel.nntp.NntpUtil.java
public static NNTPClient connectToNntpServer(NntpNewsGroup newsgroup) { NNTPClient client = new NNTPClient(); client.setDefaultPort(newsgroup.getPort()); String serverUrl = newsgroup.getUrl(); if (serverUrl.endsWith("/")) { serverUrl = newsgroup.getUrl().substring(0, newsgroup.getUrl().lastIndexOf("/")); }/*from www . j a v a2 s . c o m*/ try { client.connect(serverUrl); if (newsgroup.getAuthenticationRequired()) { client.authenticate(newsgroup.getUsername(), newsgroup.getPassword()); } } catch (SocketException e) { // TODO Auto-generated catch block System.err.println("SocketException while connecting to NNTP server: '" + newsgroup.getUrl() + "': " + e.getMessage()); e.printStackTrace(); // System.exit(1); } catch (IOException e) { // TODO Auto-generated catch block System.err.println( "IOException while connecting to NNTP server: '" + newsgroup.getUrl() + "': " + e.getMessage()); e.printStackTrace(); // System.exit(1); } return client; }