How to write a Scala shell script that reads input from STDIN

As a quick note, if you need an example of how to write a Scala shell script that reads from STDIN (standard input) and writes to STDOUT (standard output), this code shows a solution:

exec scala -savecompiled "$0" "$@"


var line = ""
while ({line = StdIn.readLine(); line != null}) {

How to prompt users for input from Scala shell scripts

This is an excerpt from the Scala Cookbook, partially modified for the internet. This is Recipe 14.12, “How to prompt users for input from Scala shell scripts.”

Back to top


You want to prompt a user for input from a Scala shell script and read her responses.

Back to top


Use the readLine, print, printf, and* methods to read user input, as demonstrated in the following script. Comments in the script describe each method:

Table of Contents

  1. Problem
  2. Solution
Back to top

Android AsyncTask - Using "Void, Void, Void" parameters (code signature)

As a quick note to self, this is how I just created an Android AsyncTask with “Void, Void, Void” parameters:

private class DeleteImagesTask extends AsyncTask<Void, Void, Void> {
    protected Void doInBackground(Void... params) {
        return null;
    protected void onPostExecute(Void param) {

A simple Android AsyncTask example

This page on the Android developer’s blog shows what is just about the simplest possible AsyncTask you can create, which is exactly what I needed just now. I started testing my Android app with StrictMode enabled this morning, and it was kind enough to remind me that I was doing some file I/O on the main thread, which is a no-no; hence the AsyncTask.

A CakePHP readonly text field

CakePHP readonly text field FAQ: Can I make a readonly textfield in CakePHP (a CakePHP Form input field, or Form text field)?

I haven't worked it all out yet, but I first tried to create a CakePHP readonly text field like this, using the CakePHP Form text object, which doesn't seem to work:

# this doesn't work
echo $this->Form->text('complexity', array('readonly' => 'readonly'));

When that failed I kept poking on the CakePHP Form input object, and was able to create a readonly text field like this:

How to prompt and read user input in a Bash shell script

Unix/Linux bash shell script FAQ: How do I prompt a user for input from a shell script (Bash shell script), and then read the input the user provides?

Answer: I usually use the shell script "read" function to read input from a shell script. Here are two slightly different versions of the same shell script. This first version prompts the user for input only once, and then dies if the user doesn't give a correst Y/N answer: