Its so frustrating when windows automatically download the windows update files without noticing us. Most of the time we are using a limited wifi network or sharing mobile data to our laptop. But windows 10 has no direct way of turning off automatic updates.
But with a little bit of work we can do it.
First go to Run and type gpedit.msc . This will open Local group policy editor of windows.
Navigate to Computer Configuration then Administrative Templates and go to Windows Components and from there locate Windows Update folder. Inside Windows Update there is a separate setting called Configure Automatic Updates. Right click on it and go to settings. From there choose disabled and apply.
Doing the above method will not disable windows updating feature, Whenever we need we can manually check for updates and install them without losing our limited internet bandwidth.
Saturday, March 25, 2017
Thursday, March 16, 2017
Java Chat Application, Class Chat Client Creation
Creating a chat application using java, creating class Chat Client
Class ChatClient
This class implements the chat client, as described. This involves setting up a basic user interface, handling user interaction, and receiving messages from the server.
import java.net.*; import java.io.*; import java.awt.*; public class ChatClient extends Frame implements Runnable { // public ChatClient (String title, InputStream i, OutputStream o) ... // public void run () ... // public boolean handleEvent (Event e) ... // public static void main (String args[]) throws IOException ... }
The
ChatClient
class extends Frame
; this is typical for a graphical application. We implement the Runnable
interface so that we can start a Thread
that receives messages from the server. The constructor performs the basic setup of the GUI, the run()
method receives messages from the server, the handleEvent()
method handles user interaction, and the main()
method performs the initial network connection.protected DataInputStream i; protected DataOutputStream o; protected TextArea output; protected TextField input; protected Thread listener; public ChatClient (String title, InputStream i, OutputStream o) { super (title); this.i = new DataInputStream (new BufferedInputStream (i)); this.o = new DataOutputStream (new BufferedOutputStream (o)); setLayout (new BorderLayout ()); add ("Center", output = new TextArea ()); output.setEditable (false); add ("South", input = new TextField ()); pack (); show (); input.requestFocus (); listener = new Thread (this); listener.start (); }
The constructor takes three parameters: a title for the window, an input stream, and an output stream. The
ChatClient
communicates over the specified streams; we create buffered data streams i and o to provide efficient higher-level communication facilities over these streams. We then set up our simple user interface, consisting of theTextArea
output and the TextField
input. We layout and show the window, and start a Thread
listener that accepts messages from the server.public void run () { try { while (true) { String line = i.readUTF (); output.appendText (line + "\n"); } } catch (IOException ex) { ex.printStackTrace (); } finally { listener = null; input.hide (); validate (); try { o.close (); } catch (IOException ex) { ex.printStackTrace (); } } }
When the listener thread enters the run method, we sit in an infinite loop reading
String
s from the input stream. When a String
arrives, we append it to the output region and repeat the loop. An IOException
could occur if the connection to the server has been lost. In that event, we print out the exception and perform cleanup. Note that this will be signalled by an EOFException
from thereadUTF()
method.
To clean up, we first assign our listener reference to this
Thread
to null
; this indicates to the rest of the code that the thread has terminated. We then hide the input field and call validate()
so that the interface is laid out again, and close the OutputStream
o to ensure that the connection is closed.
Note that we perform all of the cleanup in a
finally
clause, so this will occur whether an IOException
occurs here or the thread is forcibly stopped. We don't close the window immediately; the assumption is that the user may want to read the session even after the connection has been lost.public boolean handleEvent (Event e) { if ((e.target == input) && (e.id == Event.ACTION_EVENT)) { try { o.writeUTF ((String) e.arg); o.flush (); } catch (IOException ex) { ex.printStackTrace(); listener.stop (); } input.setText (""); return true; } else if ((e.target == this) && (e.id == Event.WINDOW_DESTROY)) { if (listener != null) listener.stop (); hide (); return true; } return super.handleEvent (e); }
In the
handleEvent()
method, we need to check for two significant UI events:
The first is an action event in the
TextField
, which means that the user has hit the Return key. When we catch this event, we write the message to the output stream, then call flush()
to ensure that it is sent immediately. The output stream is a DataOutputStream
, so we can use writeUTF()
to send a String
. If an IOException
occurs the connection must have failed, so we stop the listener thread; this will automatically perform all necessary cleanup.
The second event is the user attempting to close the window. It is up to the programmer to take care of this task; we stop the listener thread and hide the
Frame
.public static void main (String args[]) throws IOException { if (args.length != 2) throw new RuntimeException ("Syntax: ChatClient <host> <port>"); Socket s = new Socket (args[0], Integer.parseInt (args[1])); new ChatClient ("Chat " + args[0] + ":" + args[1], s.getInputStream (), s.getOutputStream ()); }
The
main()
method starts the client; we ensure that the correct number of arguments have been supplied, we open aSocket
to the specified host and port, and we create a ChatClient
connected to the socket's streams. Creating the socket may throw an exception that will exit this method and be displayed.Friday, March 10, 2017
What is Spring Framework?
The Spring Framework is an application frameworkand inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform.
https://www.youtube.com/watch?v=-weKK-oNuhA
https://www.youtube.com/watch?v=-weKK-oNuhA
Saturday, March 4, 2017
Technology today is so evolving. The purpose of keyboard keys fulfilled by bananas.
https://youtu.be/3LmaCkczLcU
https://youtu.be/3LmaCkczLcU
Subscribe to:
Posts (Atom)
Implemting Google Drive File Uploader using OAuth
Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...
-
What it is? AngularJS is a very powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. It extends HTML DOM ...
-
Technology today is so evolving. The purpose of keyboard keys fulfilled by bananas. https://youtu.be/3LmaCkczLcU
-
Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...