Get Some Free Products at your Door Step. Just feed ur Address in dis Link...!!

Saturday, March 31, 2012

Url source code fetcher

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class sourceFetcher
{
public static String fetchSource(String s)
{
String line,code="";
try {
URL url = new URL("http://"+s);
String temp="";
BufferedReader reader=null;
try
{
reader = new BufferedReader(new InputStreamReader(url.openStream()));
while((line=reader.readLine())!=null)
{
code=code+"\n"+line;
}
reader.close();
}catch(Exception e){return "error";}
}catch(Exception e){ return "error";}
return code;

}
}

Run Dos through Java

import java.io.IOException;
public class RunDos
{
public static void runCommand(String command) throws IOException, InterruptedException
{
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
}
}

WordSeperator

public class WordSeperator
{
public static Object[] seperater(String source)
{
String word;
int start=0,end=0;
ArrayList a=new ArrayList();
for(int pos=0;pos {
if(source.charAt(pos)==' ')
{
end=pos;
word=source.substring(start, end);
if(word.length()>1)
a.add(source.substring(start, end));
start=end+1;
}
}
a.add(source.substring(end+1, source.length()));
return a.toArray();
}
}

Monday, March 19, 2012

Toast Message in Android App

package prem.firstApp;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class FirstAppActivity extends Activity implements OnClickListener
{
Button b1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b1=(Button)findViewById(R.id.b1id);
b1.setOnClickListener(this);
}

@Override
public void onClick(View v)
{
Toast.makeText(this, "Hello, This is my First App", Toast.LENGTH_LONG).show();
}
}

Configure Eclipse for Android Development


1. Go to http://www.eclipse.org/downloads/
2. Choose Eclipse IDE for Java Developers (32 bit/64 bit as per your choice)
3. Choose eclipse-java-indigo-SR2-win32 for better result and unzip it.
4. Open Eclipse by clicking on eclipse icon
5. Click ok when it will opt address for WorkSpace
6. Help>Install new Softwares>Add>
7. fill Name=> Android ADK
Location => http://dl-ssl.google.com/android/eclipse
8. ok and then install the software.
Now
9. Go to Windows>Preferences>Android option in left Panel>Browse
Set path of sdk locations>Apply + OK


Saturday, March 17, 2012

larger no. among 3 numbers

#include
#include
void main()
{
int a=10,b=20,c=30;
printf("%d",a>b ? a>c?a:c:b>c?b:c);
}