Txtweb postcode sample code

Txtweb postcode sample code

What is Txtweb ?

Txtweb is a web platform which can be accessed by the sms for free of cost. Here Anyone can deploy any app and which can be accessed worldwide.

Do you want to learn how to program in txtweb ? then Learn and start now.

I have deployed one app named postcode in the txtweb and the below is the source code of the app,

package in.javadomain;

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

import org.json.JSONException;
import org.json.JSONObject;

public class PostCode {

	public static void main(String[] args) {
		PostCode pc = new PostCode();
		String postCode = pc.getPostCode("arcot");

	public String getPostCode(String placeName) {
		String postCode = null;
		try {
			URL url = new URL("http://www.getpincode.info/api/pincode?q="
					+ placeName + "");
			URLConnection connection = url.openConnection();
			String line;
			StringBuilder builder = new StringBuilder();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
			while ((line = reader.readLine()) != null) {

			JSONObject json = new JSONObject(builder.toString());
			System.out.println("PostCode of " + placeName + " is  "
					+ json.get("pincode"));
		} catch (IOException e) {
			postCode = "Server May be Busy, Try Again Later!";
		} catch (JSONException e) {
			postCode = "Server May be Busy, Try Again Later!";
		return placeName + "<br>" + "App By Javadomain.in";


[plain gutter=”false”]
PostCode of arcot is 632503

Thanks for reading this article. If you found anything wrong then kindly let me know.

627 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.