Kayıtlar

Parsing a URL

Sample - 1 import java.net.*; import java.io.*; public class ParseURL { public static void main(String[] args) throws Exception { URL aURL = new URL("http://example.com:80/docs/books/tutorial" + "/index.html?name=networking#DOWNLOADING"); System.out.println("protocol = " + aURL.getProtocol()); System.out.println("authority = " + aURL.getAuthority()); System.out.println("host = " + aURL.getHost()); System.out.println("port = " + aURL.getPort()); System.out.println("path = " + aURL.getPath()); System.out.println("query = " + aURL.getQuery()); System.out.println("filename = " + aURL.getFile()); System.out.println("ref = " + aURL.getRef()); } } Here is the output displayed by the program: protocol = http authority = example.com:80 host = example.com port = 80 path = /docs/boo...

Quick and easy image resizing with Java ImageIO

Quick and easy image resizing with Java ImageIO There are quite a lot of examples of image resizing floating around the web but they all seem to access all sort of hidden features and classes deep inside the JDK to achieve their goal. Here is the most straightforward method that I could come up with - all in all just 5 lines of code. It requires ImageIO and requires Java 1.4 or later to run. If the ImageIO.write() method accepted plain ol' AWT Image arguments it could have been reduced further still to three lines, but you have to give it a BufferedImage instance as input. The snippet below assumes that there exist the following variables (coloured green in the code): an input stream to read from a desired width variable (specifying the height as -1 tells the toolkit to preserve the original aspect ratio) and an output stream to write the encoded image to. Sample code: import java.awt.Image; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; // .....

Get Images from link and store in movie folder on andriod

                            URL url = new URL(R.string.VM_01 + "movie_image/scene/kung_fu_panda_2/kung_fu_panda_2_1.jpg");                             InputStream is = url.openStream();                             OutputStream os = new FileOutputStream( "movie/pic/large/kung_fu_panda_2_1.jpg");                                                   ...

Android Simple Http Get Request without any Parameter

                    String result="";                     HttpClient httpclient = new  DefaultHttpClient();                                         // Prepare a request object                     HttpGet link = new HttpGet("http://12.133.183.155:8081/MCP/media/getMediaItems?page=1&pagesize=1");                                         // Execute the request                  ...

Short information about the first iphone development

Resim
The @autoreleasepool statement supports the Automatic Reference Counting (ARC) system. ARC provides automatic object-lifetime management for your app, ensuring that objects remain in existence for as long as they're needed and no longer. The call to UIApplicationMain creates an instance of the UIApplication class and an instance of the app delegate (in this tutorial, the app delegate is HelloWorldAppDelegate , which is provided for you by the Single View template). The main job of the app delegate is to provide the window into which your app’s content is drawn. The app delegate can also perform some app configuration tasks before the app is displayed. ( Delegation is a design pattern in which one object acts on behalf of, or in coordination with, another object.) In an iOS app, a window object provides a container for the app’s visible content, helps deliver events to app objects, and helps the app respond to changes in the device’s orientation. The window itself...

How to loop ArrayList in Java

No nonsense, four ways to loop ArrayList in Java For loop For loop (Advance) While loop Iterator loop package com.mkyong.core ;   import java.util.ArrayList ; import java.util.Iterator ; import java.util.List ;   public class ArrayListLoopingExample { public static void main ( String [ ] args ) {   List < String > list = new ArrayList < String > ( ) ; list. add ( "Text 1" ) ; list. add ( "Text 2" ) ; list. add ( "Text 3" ) ;   System . out . println ( "#1 normal for loop" ) ; for ( int i = 0 ; i < list. size ( ) ; i ++ ) { System . out . println ( list. get ( i ) ) ; }   System . out . println ( "#2 advance for loop" ) ; for ( String temp : list ) { System . out . println ( temp ) ; }   System . out . println ( "#3 while loop" ) ; int j = 0 ; while ( list. size ( ) > j ) { System . out . println ( list. get ( j ...

Start Apache and Tomcat Commands

Start Apache and Tomcat Start Apache: $APACHE_HOME / bin / apachectl -k start To stop use: $APACHE_HOME / bin / apachectl -k stop Start Tomcat: $TOMCAT_HOME / bin / startup.sh Stop Tomcat: $TOMCAT_HOME / bin / shutdown.sh