Small but a cool and an old trick for copy-pasting Java code in Eclipse.
I have seen so many folks are still doing this when they want to copy-paste the Java code from the net via clipboard in their Eclipse.
>Right click on the target folder where you want clipboard Java code
>New
>Create Class
>Give a name and then finally remove the default code in this class and paste the Java code from their clipboard.
You don't need to do all this. Just Right-click on the target folder where you want this Java code and paste from the clipboard or directly CTRL+V.
Nice- isn’t it? Sample code: package com.test.apiAutomation.test; import java.util.HashMap; import java.util.Map; import org.testng.annotations.Test; public class TestCopyPaste { @Test public static void testCopyPaste() { Map<String, String> formParams = new HashMap<String, String>(); formParams.put("grant_type", "hey"); System.out.println("It's working, TADAAAA..."); } } What Eclipse has done here? - It has parsed the clipboard content and detected that Java code was available, so it made the necessary changes and then copied it.
Nice- isn’t it? Sample code: package com.test.apiAutomation.test; import java.util.HashMap; import java.util.Map; import org.testng.annotations.Test; public class TestCopyPaste { @Test public static void testCopyPaste() { Map<String, String> formParams = new HashMap<String, String>(); formParams.put("grant_type", "hey"); System.out.println("It's working, TADAAAA..."); } } What Eclipse has done here? - It has parsed the clipboard content and detected that Java code was available, so it made the necessary changes and then copied it.
Comments
Post a Comment