Updates from July, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 8:17 pm on July 2, 2012 Permalink |
    Tags: , input, io, , , output,   

    My most favorite methods – part 2 

    Okay, here’s the second one. And it took me a few months to write this one 😛

    /**
     * Copies from an {@link InputStream} to an {@link OutputStream}
     *
     * @param from
     * @param to
     */
    public static void copyStream(InputStream from, OutputStream to)
    {
    	byte[] contents = null;
    	int count = -1;
    
    	if ((null != from) && (null != to))
    	{
    		try
    		{
    			contents = new byte[1024];
    			while (-1 != (count = from.read(contents)))
    			{
    				to.write(contents, 0, count);
    			}
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    		finally
    		{
    			contents = null;
    		}
    	}
    }
    

    This method copies the contents from the input stream to the output stream. Do I need to explain more?

    Advertisements
     
    • Andy Res 9:14 pm on July 2, 2012 Permalink

      It’s funny the way how you write the condition in the if and while loop, like you are checking the “null” and “-1” against your variables, which seems unusual for me. 🙂
      I would write instead if(from!=null), and while((count=from.read(contents))!=-1) ..

    • Subinkrishna G 11:09 am on July 3, 2012 Permalink

      This is one practice that I follow from beginning 😉

  • Subinkrishna Gopi 4:17 pm on November 24, 2011 Permalink |
    Tags: , groovy, hello world, , scripting   

    Hello, Groovy! 

    My new job demands me to learn a lot of new things that I never wanted to! Today I wrote my first ever Groovy script. And it compiled and run! Awesome 🙂

    package subin.groovy;
    
    /**
     * Hello, World!
     *
     * @author Subinkrishna Gopi
     */
    class HelloWorld
    {
    	static def aString = "Hello, World!"
    	static void main(args)
    	{
    		println("${aString.toUpperCase()} it's a nice day today :)")
    	}
    }
    
     
  • Subinkrishna Gopi 6:11 pm on October 8, 2011 Permalink |
    Tags: , readability, , , ,   

    Today’s read: 16 Pixels For Body Copy. Anything Less Is A Costly Mistake. 

    Smashin Magazine

    16 Pixels For Body Copy. Anything Less Is A Costly Mistake

    A very good article on why we should keep bigger (and better) font sizes. I totally agree with the author. I hate the small font size Facebook uses. That gives me a bad head ache and I always use the browser zoom for better readability.

    I know what you’re thinking. “Did he just say 16 pixels? For body copy? Obnoxiously big! 12 pixels is ideal for most websites.”

    I’d like to persuade you otherwise.

    Have a nice read.

     
  • Subinkrishna Gopi 2:41 pm on October 5, 2011 Permalink |
    Tags: , database, db2,   

    An encounter with DB2 – How to apply “limit” to queries? 

    My new assignment wanted me to experiment with DB2. And like everyone else who is new to DB2, I couldn’t find a way to limit the result set! After a lot of googling and phone calls I ended up with a stupid solution – but it works.

    The solution looks like this:

    SELECT * FROM
    	( SELECT ROW_NUMBER() OVER (ORDER BY column_to_be_sorted) AS rownumber, col1, col2, other_cols
    	  FROM my_db2_table WHERE col1 = ‘something’ )
    AS tmp_table
    WHERE rownumber BETWEEN start_index AND end_index
    

    I hope this helps. But I really wish if there was some better ways.

     
  • Subinkrishna Gopi 3:29 pm on November 4, 2010 Permalink |
    Tags: , , , ,   

    Today’s read – How To Build A Mobile Website 

    This one is really helpful. How To Build A Mobile Website. This article talks about the stylesheets, mobile stylesheets, customizing them, how to reduce the bandwidth usage and handling iPad/iPhone.

    Over the past few years, mobile web usage has considerably increased to the point that web developers and designers can no longer afford to ignore it. In wealthy countries, the shift is being fueled by faster mobile broadband connections and cheaper data service.  However, a large increase has also been seen in developing nations where people have skipped over buying PCs and gone straight to mobile.

    Unfortunately, the mobile arena introduces a layer of complexity that can be difficult for developers to accommodate.  Mobile development is more than cross-browser, it should be cross-platform.  The vast number of mobile devices makes thorough testing a practical impossibility, leaving developers nostalgic for the days when they only had to support legacy browsers.

    Source: Smashing Magazine

    Read the article

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel