Live internet radio stream extractor

radio.jpg

Friends,

This is to give you a code pack I wrote today. I was listening to one of the internet radios in Tamil. I want to store it on my hdd, the tools I searched dint helped me much. I want a simple tool, that saves my time. And It should be able to work in my absence. I wrote couple of classes, which I am going to test it now.

Why dont you test it youself 🙂
It doesnt require any installation. you need only three files.

mp3_stream_extractor.jar, The execution binary,
RUN.CMD, the invoking script
radio.properties, where you configure the radios

run the run.cmd, The audio is extracted to your home folder automatically.

Enjoy.

Download MP3 stream extractor

radio properties

java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence

Hi,

I have taken a short break! There are many more error messages, which are keep on accumulating behind the screens. But I am so lazy to put them in grassfield.

Anyway, today I got interrupted with an interesting exception

java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence

The scenario was, I am trying to parse an xml string. I am taking the byte array from the xml string, and give that array as input to xml reader stream. I have used java.lang.String.getBytes() for this.

Unfortunately, I got a chinese (or any other funny) characters as a value of one node in the xml. Ooof. I got up with the above error. Later, I found that getBytes() method supports only the western encoding, not UTF-8. So by using java.lang.String.getBytes("UTF-8") method, we solved the issue! nice na!

Java Runtime exec can hang

Today I was trying to extract the windows eventlog entries in my win-xp box. I have used Eldump to do this. please see my earlier post about this tool http://blog.grassfield.org/2007/06/24/fetch-your-eventlog-entries-with-eldump/ . I have used runtime.exec() to execute this command and extracted the information from the process streams.

The program was extracting the log entries, but hang in between, and went for endless sleep; i.e, the process never ended. Later with some googling, I was adviced to read error stream first, and then process output stream. Also both the streams need to be read concurrently with two threads. This could solve my issue. Try then!

java.util.zip.ZipException: invalid CEN header (encrypted entry)

friends,This week started with some more problems :). Nothing to worry, problems only feed us! Otherwise, who will give us job!!! Today I was trying to unzip a zip file and read the contents inside the file, using java.util.zip.ZipFile. It was working fine till I increased the file size. The zip file is around 160MB, and the single file inside that zip file is 4.5GB contains raw text. I hit with the exception

java.util.zip.ZipException: invalid CEN header (encrypted entry)

Pathetic, I was totally helpless! Later I came to know that It is a open bug in java, which will not support above 3.2G!  I am in darkness. Latermy lead had pointed out that is due to java’s non-compliance to zip64, which is fixed in jdk1.6, 24th build. I need to get it installed and get rid of this issue!

Make fun with Text : java.util.Scanner


One of my friend came with the sun’s newsletter today morning. I was wondering about their demo on a new class, java.util.Scanner
See, parsing the string becomes very simple, like iterating a list.

Scanner accepts streams, file and other string input mechanisms and parses the string and give is the tokens. (It also allows the user to specify using which encoding the text has been built. goo news for localisation guyz like me). By default, whatever you have given, it is tokenized by having the default delimiter, space, See the following example,

import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

The output is

C:>java test
import
java.util.*;
import
java.io.*;
public
class
test
{
public
static
void
main(String
[]
args)
throws
FileNotFoundException
{
File
f
=
new
File(“test.java”);
Scanner
scanner
=
new
Scanner(f);
while
(scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

funny, isnt it!!!

We can also change the delimiter, see the following example

import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
scanner.useDelimiter(“n”);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

The output is same as that of above code, want to see that one also?

C:>java test
import java.util.*;
import java.io.*;
public class test
{
public static void main(String [] args) throws FileNotFoundException
{
File f = new File(“test.java”);
Scanner scanner = new Scanner(f);
scanner.useDelimiter(“n”);
while (scanner.hasNext())
{
System.out.println(scanner.next());
}
scanner.close();
}
}

Really good one! But I really miss the fun of using the streams 😦

How to display tamil text with java5 (applets and java swing based applications)

Java 1.3+ should display tamil without altering anything. but jre is
not configured for tamil officially till now. (Devanagari is added).
So you will see only boxes in applets or any other swing applications.
here is the procedure to see tamil characters.

It is considered you have Latha font installed.

Open java directory then go into ‘jre’ directory. Copy-Paste the
“fontconfig.properties.src” file, and rename it as
“fontconfig.properties”.This file then should be the one Java will use
by default. now open the “fontconfig.properties” file.

Find this line :

# Component Font Mappings

Then add :

allfonts.tamil=Latha

You must then find

sequence.allfonts=alphabetic

/default,dingbats,symbol

and add tamil: (am not sure, whether it is really to be done. it
worked without this entry)
sequence.allfonts=alphabetic/default,dingbats,symbol,tamil

add the line

sequence.allfonts.UTF-8.ta=alphabetic/1252,tamil,dingbats,symbol

restart if you are using any java applications. and restart the
browser (deleting temporary files may help if it dint reflect)

post a message, if anything dint work as expected.

-p.

serialVersionUID

I found eclipse is continuously warning me about ‘serialVersionUID’
whenever i tried to save a Java file. I was thinking that there will
be a relation between jdk version in which the class has been created.
please see http://www.javaworld.com/javaworld/jw-02-2006/jw-0227-control.html

Java serialisation provides a serialisation id serialVersionUID or
suid for version control. this informs the java serialisation
mechanism which class version is suitable with that serialised object.

ooff…


—————————————————
*Free* software is a matter of liberty not price. You should think of
“free” as in “free speech”.