28 March 2011

ReadFile Encoding UTF-8 - java

ReadFile Encoding UTF-8 - java
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadUTF8Data {
    private static final String FILE_ENCODE = "UTF-8";
    public static void main(String[] args) {
        String data = null;
        BufferedReader dataIns = null;
        String file = "";
        try {
            dataIns = new BufferedReader(new InputStreamReader(
            new FileInputStream(file), FILE_ENCODE));
            
            while ((data = dataIns.readLine()) != null) {
                System.out.println("Line 1 :" + data);
            }
            dataIns.close();
            dataIns = null;
            } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

15 March 2011

mysql server เข้าใช้ได้จากเครื่องอื่น

mysql server เข้าใช้ได้จากเครื่องอื่น แก้ไฟล์ /etc/mysql/my.cnf
bind-address  = 127.0.0.1
เป็น
#bind-address  = 127.0.0.1
กำหนดสิทธิ์การเข้าใช้ Database
mysql> GRANT ALL ON DB_NAME.* TO 'USERNAME'@"%" IDENTIFIED BY 'NEW_PASSWORD';

08 March 2011

Turn on Bash Smart Completion

Turn on Bash Smart Completion The Bash shell has this sweet feature where you can use the TAB key to auto-complete certain things. For example, when I am in my home directory, the following command:
cd Do[TAB-key]
will automatically yield:
cd Documents
If you are an absolute novice, like I was, not so long ago, discovering tab completion in the terminal can make you go “Wow!”. Wait till you hear the rest now Though you can use the TAB key to complete the names of files and directories, by default the completion is pretty “dumb”. If you have already typed
cd D
you would expect that the tab key would cause only the directory names to be completed, but if I try it on my machine, the tab completion tool uses filenames too. Now, don’t despair! There is now a smart bash tab completion trick you can use. Smart completion even complete the arguments to commands!! To enable smart completion, edit your
/etc/bash.bashrc
file. Uncomment the following lines, by removing the # in the beginning of the lines:
#if [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
#fi
Now you can use tab completion to power your way through commands. You can even extend bash smart completion to your own favourite commands
by using , the “complete” utility and
Explaining the nitty-gritty is beyond me. I refer you to the Debian Administration gurus for more information regarding smarter bash completion.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Blog by Chagridsada Boonthus | http://chagridsada.blogspot.com/