Sending arguments into Java native application

THE PROBLEM: Write a program that will read an input file mentioned in your command line, and display several lines of text from the input file.

THE SAMPLE OUTPUT:

image

In this tutorial we need simple code editor (Notepad++) and JDK (Java Development Kits). If you’re using Mac, JDK is already available inside (read more for Mac user).

Iklan Pertandingan Kemahiran Malaysia (PKM) 2012

 

skillmalaysia

Kepada pelajar-pelajar IPTA / IPTS/Pusat Latihan Kemahiran / etc bawah 20 tahun jangan lepaskan peluang untuk memenangi sehingga RM5000.00 wang tunai (pingat emas) dalam Perandingan Kemahiran Malaysia 2012. Manakala untuk pingat perak (RM2500) dan gangsa pula (RM1500).

Antara kategori yang dipertandingkan adalah IT Software Solutions, IT Systems Network, Web Design dan Graphic Design untuk bidang kemahiran Teknologi Maklumat.

Web Design – adalah kategori merekabentuk dan membangun laman web. Ia memberi peluang kepada anda menggunakan beberapa perisian pembangunan laman web dan rekabentk grafik untuk menyiapkan laman web yang cantik dan menarik. Disamping itu anda juga perlu mempunyai kemahiran pengaturcaraan sebelah-pelayan (server-site scripting) untuk menggabungkan elemen pangkalan data dalam laman web tersebut.

IT Software Solutions – merupakan kategori yang menguji kemahiran anda dalam penggunaan aplikasi asas perkomputeran seperti pemprosesan perkataan, lembaran kerja dan perisian pembentangan.

IT Systems Network – memerlukan anda mahir dalam bidang pemasangan perkakasan komputer, menginstall perisian terlibat dan menyelenggara rangkaian.

Graphic Design – anda akan ditugaskan untuk menghasilkan pakej grafik, seperti bungkusan produk, untuk anda memperlihatkan kemahiran merekabentuk grafik kreatif.

Setiap kategori mengandungi dua peringkat; saringan dan peringkat akhir. Untuk sampai peringkat akhir, para peserta perlu memasuki saringan yang akan diumumkan kelak.

Tidak perlu bayar apa-apa, cuma gunakan kemahiran anda untuk menang dan berpeluang untuk mewakili Malaysia di peringkat dunia.

Tarikh tutup penyertaan pada 30 Januari 2012. Sila daftar di http://daftar.skillsmalaysia.gov.my/regman/events/32/registration

Untuk maklumat lanjut, sila layari:

http://www.skillsmalaysia.gov.my/index.php?option=com_content&view=article&id=207:iklan-dan-pendaftaran-pertandingan-kemahiran-malaysia-pkm-dan-myskills-2012-&catid=41:latest1

Calculating word frequency

This is a simple application to calculate word frequency in a MultiByte String. MultiByte String relates to Unicode representation of String (used in Jawi or Arabic).

calculate word frequency in a MultiByte String

The PHP code;


<html>
<head>
<title>Maklumat tulisan Arab</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<script type="text/javascript" src="keyboard.js" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="keyboard.css">
<script type="text/javascript">

var currentFocussedElement = null;

function enterLetter(sender)
{
if(currentFocussedElement)
currentFocussedElement.value += sender.innerHTML;
}

</script>
</head>
<body>


<form action="index.php" method="post">

<input type="text" name="fname" size="50" tabindex="1" onFocus="currentFocussedElement = this" class="keyboardInput"/>
<input type="submit" />
</form>

<hr>

<?php $text = $_POST["fname"];

if ($text!=NULL){
//$words = str_word_count($text, 1); // use this function if you only want ASCII
$words = utf8_str_word_count($text, 1); // use this function if you care about i18n

$frequency = array_count_values($words);

?>
<table border=1>
<tr> <td>perkataan </td><td>frekuensi </td></tr>
<?php
while ($eachword = current($frequency)) {
echo "<tr> <td>".key($frequency)." </td><td>". $eachword." </td></tr>";
//echo key($frequency);

next($frequency);
}


?>
</table>
<?php
}//end if NULL
?>

<?php
//tokenizer function
function utf8_str_word_count($string, $format = 0, $charlist = null)
{
$result = array();

if (preg_match_all('~[\p{L}\p{Mn}\p{Pd}\'\x{2019}' . preg_quote($charlist, '~') . ']+~u', $string, $result) > 0)
{
if (array_key_exists(0, $result) === true)
{
$result = $result[0];
}
}

if ($format == 0)
{
$result = count($result);

}

return $result;
}
?>



How to pause Audio while Call is Incoming–Android

How to pause Audio while Call is Incoming in AndroidWhile developing m-mathurat, I have this problem on handling incoming call while playing the audio for the recitation. The recitation audio is the main feature of m-mathurat, however as a phone, CALLs are the top priority. I don’t want the recitation audio to interfere the conversation. Previously, the incoming call interrupts is not even thought of. As the consequence of neglecting this issue, I can hear the recitation sound while talking to a caller. This does disturb me coz I cannot here the caller voice clearly.

I notice this problem may occur in Android 2.1 and 2.2. However in Gingerbread (Android 2.3) this issue is handle automatically by the Android OS itself. Any audio playing while talking to a caller, will be minimized. Meaning that you still can only hear the audio/song however not too loud (considered not disrupting the conversation).

This tutorial is continuation of previous tutorial available here http://blog.kerul.net/2011/07/sound-manipulation-in-using-mediaplayer.html

Adding uses-permission to read the phone state

But before that, you must put this uses-permission in the AndroidManifest.xml (since this is considered a privacy issue, so telling the user prior installation is a must).

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

The special class PhoneStateListener


The solution is related to a class named PhoneStateListener. I put it in the main activity class. This is the class to handle the Phone-State change. If there’s incoming / outcoming call, this class will be invoked.


Layout - WebView on top of buttons in Android app

WebView on top of buttons in Android appFigure 1

It has been a while since I’ve been researching for this capability. I need to design a layout that has a WebView on top of a row of buttons. Found a sample in StackOverFlow and it was a relieve at the end. Credit to jkhouw1.

  • By using the RelativeLayout, a view can be arrange dependent to the other view.
  • I set a LinearLayout for the buttons and providing and id=buttonlayout
  • The WebView need to specify this android:layout_above="@id/buttonlayout"