title: Find and print to network printer by IP address in Java
body: <p>I've read tons of similar questions and haven't gotten anywhere.. </p>
  
  <p>What I'm trying to do is connect to a printer directly by IP (not one that's in my windows devices list) and print a document to it. </p>
  
  <p>Here's what I've tried so far (didn't work, no idea why):</p>
  
  <pre><code>try{
      Socket sock = new Socket("1.2.3.4", 9100);
      PrintWriter oStream = new PrintWriter(sock.getOutputStream());
          oStream.println("Hello World");
          oStream.close();
          sock.close(); 
  }
  catch (UnknownHostException e){
      e.printStackTrace();
  } 
  catch (IOException e) { 
      e.printStackTrace();
  }
  </code></pre>