Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Newsletters Archive: 14

JavaFAQ Home » Java Newsletters Go to all tips in Java Newsletters


Bookmark and Share

******************************************************************
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* > The Java FAQ Daily Tips, weekly publication < *
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *
* *
* Issue No: 14 6 December 2000 *
* http://www.javafaq.nu/java *
* *
* *
* Please recommend us and our FREE "100 Java Tips" book to your *
* friends and colleagues! *
* http://javafaq.nu/java/advert/our_book.shtml *
******************************************************************

Table of Contents

1. Is it possible for a minimized window in MS Windows task bar
to start blinking?
2. How do I indicate Unicode characters that cannot be represented
in ASCII, such as ц?
3. Can I pass a function as a parameter in Java? If so, how?
4. How do I find the list of all system properties?
5. ... Finally I found that Java API has a bug!
6. I need to store an object NOT a string in a cookie.
Is that possible?
7.
******************************************************************

Hello dear friends!

We published pdf-version (Acrobat Reader) of our "100 Java Tips"
http://javafaq.nu/java/advert/our_book.shtml Check here!
So it is possible for all of you to read this book now!

We will regularly update this book (every 2-3 weeks). So one nice
beautiful sunny day you will discover that your "100 Java Tips"
become "100's Java Tips"! Please feel free to present it to your
friends, colleagues and just good people!

Today we built in into our site the searching engine that will let
you do additional search of Java resources (really any web resources!)
on whole web without leaving our site.
This engine has more than 2,000,000 best active links in the
continuously growing database with description!
All links are selected by people (not by automated web spider program)!
Please take a look! And report us if smth. doesn't work properly.

We receiving many letters with questions. We are trying answer you,
but unfortunately we have no enough time to answer all people.
Often it takes too much time to investigate the problem.
Please ask your questions and help each other at our Java Forum:
http://javafaq.nu/cgi-bin/UltraBoard/UltraBoard.cgi?action=Headlines&BID=1

******************************************************************

Tip 1

Q: Is it possible for a minimized window in MS Windows task bar
to start blinking? In any IRC client a minimized window starts
blinking when a new message appears in it. Is it possible in Java?

Answer:
I doubt very much that it is possible with pure java; you would
have to use some native code to achieve that. Maybe what you could
try though, is to play around with the icon used in the title bar
of the frame. I haven't tried this myself - and in any case I'm
running linux, but it might be possible to have two icons and to
switch them around at some rate using the Frame.setIconImage(Image)
method. This will only affect the icon itself - not the whole
window, but it's better than nothing.

******************************************************************

Tip 2

Q: How do I indicate Unicode characters that cannot be represented
in ASCII, such as ц?

Answer: from "Java Tutorial
(http://java.sun.com/docs/books/tutorial/i18n/text/convertintro.html)
"To indicate Unicode characters that cannot be represented in ASCII,
such as o, we used the uXXXX escape sequence. Each X in the escape
sequence is a hexadecimal digit. The following example shows how to
indicate the o character with an escape sequence:

String str = "u00F6";
char c = 'u00F6';
Character letter = new Character ('u00F6'); "

******************************************************************

Tip 3

Q: Can I pass a function as a parameter in Java? If so, how?

A: No, you cannot. But you can pass an object with method and then
just use this method like this:

myFunction (object); // object has method useMyMethod(){ do smth here...}
..
..
somewhere in another place where use this function..
object.useMyMethod();

******************************************************************

Tip 4
Q: How do I find the list of all system properties?

Answer: do smth like this:

Enumeration list = System.getProperties().propertyNames();
while(list.hasMoreElements()){
System.out.println((String) list.nextElement());
}
}

******************************************************************

Tip 5

When I tried to read one string representing boolean value and
convert it into boolean it didn't work. Finally I found that Java
API has a bag!
Q: I wrote the program that uses redaing ini file settings for
initialization. All settings in a file are strings. I am converting
them to appropriate type during reading. When I tried to read one
string representing boolean value and convert it into boolean it
didn't work. Finally I found that Java API has a bag:

boolean x = true;
getBoolean(x);
will show false!!!!

Why Java has method that doesn't work? Is it bug in Java
or I am stupid?

A: neither statement is true! It is not a bug and you are Ok! Just
please read more carefully JavaDoc next time.

It is written there for getBoolean ():
"Returns is true if and only if the system property named by the
argument exists and is equal to the string "true". (Beginning with
Java 1.0.2, the test of this string is case insensitive.)
A system property is accessible through getProperty, a method
defined by the System class."

So you didn't use this method properly...
Use instead:

public static Boolean valueOf(String s)

This method returns the boolean value represented by the specified
String. A new Boolean object is constructed. This Boolean contains
the value true if the string argument is not null and is equal,
ignoring case, to the string "true".

example:
boolean x= true;
(Boolean.valueOf(x)).booleanValue()
gives you proper boolean (not Boolean!) value


******************************************************************

Tip 6

Hi, I am using servlets. I need to store an object NOT a string
in a cookie. Is that possible? The helpfile says BASE64 encoding
is suggested for use with binary values. How can I do that???

Answer: You could serialize the object into a ByteArrayOutputStream
and then Base64 encode the resulting byte []. Keep in mind the size
limitations of a cookie and the overhead of transporting it back
and forth between the browser and the server.
Limitations are:
* at most 300 cookies

* at most 4096 bytes per cookie (as measured by the characters
that comprise the cookie non-terminal in the syntax
description of the Set-Cookie2 header, and as received
in the Set-Cookie2 header)

* at most 20 cookies per unique host or domain name
For more details please refer to RFC 2965.

******************************************************************

Tip 7

Q: How can I read a Tab delimited text file into a JList?
All I need is the first item in each record. I import each line
with a BufferedReader.Readline() and then look at each char with
record.substring(n,n+1). How can I check if the next char is a Tab?

Answer: StringTokenizer st = new StringTokenizer(record, " ");
while (st.hasMoreTokens()) {
String token = st.nextToken();
// ... do something with the token
}



The Java FAQ Daily Tips is a newsletter that is only sent to those
who have specifically subscribed to it.

John Andersson, Editor mailto:info@javafaq.nu

Copyright (c) 2000 John Andersson
******************************************************************
* *
* You can find our tips on site also! *
* Please recommend us and our FREE "100 Java Tips" book to your *
* friends and colleagues! *
* http://javafaq.nu/java/advert/our_book.shtml *
* *
******************************************************************


 Printer Friendly Page  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy