Skip to main content

Posts

Write a Java program to read console data using bufferedreader API

BufferedReader is a class which simplifies reading text from a character input stream. It buffers the characters in order to enable efficient reading of text data. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader whose read() operations may be costly, such as FileReaders and InputStreamReaders. For example, // BufferedReader in = new BufferedReader(new FileReader("foo.in")); will buffer the input from the specified file. Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream
Recent posts

Absorbing Feedback

We all want to improve, absorbing feedback is the most important step in the process of improvement. Even when we get feedback, we don't know how to act on it. We have good techniques for giving feedback like SBI (Situation, Behavior, Impact) however, it took me some time to develop a good framework to absorb and act on feedback. Let me start with a real-life situation: A couple of years back, I received feedback, however incapable of acting on it. I was struggling to make any improvement. During this phase, I developed the framework which helped me.  This framework has two attributes " Understand Deeply" and "Act Swiftly".  Understand Deeply is about understanding the feedback and situations where behaviour is depicted so that you can relate to the situation. Some situations bring out the same undesired behaviour. It is also very important to understand the intent of the feedback.  Act Swiftly talks about acting on feedback, taking steps to

Grow faster by making yourself redundant!

Redundant ! but why? What about job security? Shouldn't we be consolidating our position instead of going redundant? All these questions are obvious when you read the title of this article. Don't worry, we are not talking about how to get yourself fired but opposite, how to grow faster by making yourself redundant in a role . In a job, we are expected to play roles that are needed from us e.g. program manager, project manager, people manager, technical lead are few roles engineering managers play to be successful. This article talks about how we can progressively outgrow in our current role and start learning (or mastering) the new roles. Transferring responsibilities to people you are managing are the best way of making space for learning something new. Over the past couple of years as an engineering manager, I have been following this philosophy to learn new things. Let's take an example of leading a project to understand this better. Engineering Managers are the b

Engineering Leader: How to make a difference?

Being an engineering leader is not an easy task, especially when you are stepping into this role as a first-timer. Seldom you go through a training, however in most situations you are expected to figure it out yourself with little or no guidance. Often leadership demands you to play following roles: People Manager Product/Business knowledge Architect/Senior Developer Vision for technology I will be writing separate blogs to cover the first two roles. For a beginner, last two roles are very important to gain credibility of the team which is the most important factor in succeeding at your job. As a technical leader, you will be facing the challenges from all the directions like decision making, improving team efficiency and choosing the technology roadmap for your team. However, I hope adopting following patterns can help you sail through these challenges. Decision Making : When hit with the problem, as a techie you rely on your technical skills and often start suggesting so

Play framework 1.2.x excel export with I18n and custom filename

play-excel is a very well written plugin of Play-framework for exporting excel from java objects. I used this plugin for my requirement of generating the I18n supported xls with custom names. This blog will explain this in details so that I can use it later :). Line# 4: will basically make the play-excel to take the rendering functionality in play. (you can also use xlsx instead of "xls") Line# 5: Will set the exported filename to given name i.e. "downloadUsers.xls" Line# 6&7: pick up the template from views/ /users_ .xls. 2. public static void users() { 3. List users = User.findAll(); 4. request.format = " xls "; 5. renderArgs.put(" __FILE_NAME__ ", "downloadUsers.xls"); 6. String template = "users-" + Lang.get() + ".xls"; 7. renderTemplate (template, users); 8. } That's it you are done. Happy coding :).

Gear 2 and Gear 2 Neo working with Nexus 5

Gear 2 and Gear 2 Neo are working perfectly with Nexus 5. Please go to the following URL: http://forum.xda-developers.com/showthread.php?t=2677686 and download the " Galaxy Gear Manager " app on your phone. Launch the gear manager app and select your gear device and you are good to go. For receiving additional notifications, goto Gear Manager and select Notification item and select from the list of apps you want to receive notification from.

Simplest iterative algorithm Post order traversal

package com.test; import java.util.Stack; public class PostOrderTraversal { static class Node { int data ; Node left , right ; Node( int item ) { data = item ; left = right ; } } private void pfIterate(Node root ) { Node prev = null ; Stack stack = new Stack<>(); stack .push( root ); while (! stack .isEmpty()) { root = stack .pop(); if ( root . left == null && root . right == null ) { System. out .print( root . data + " " ); prev = root ; } else if ( prev == root . left || prev == root . right ) { System. out .print( root . data + " " ); prev = root ; } else { stack .push( root ); if ( root . right != null ) stack .push( root . right ); if ( root . left != null ) stack .push( root . left ); } } } public static void main(String[] args ) { // Let u