Monday, April 25, 2011

Remove or Change Proxy settings for apt in Ubuntu

Remove proxy settings from apt?
Try to edit your /etc/apt/apt.conf
and change it to:
Code:

Acquire::http::Proxy "false";

Remove or Change Proxy settings for apt in Ubuntu

Remove proxy settings from apt?
Try to edit your /etc/apt/apt.conf
and change it to:
Code:

Acquire::http::Proxy "false";

Mounting NTFS (Windows) drive automatically in Ubuntu

Add the following line in you /etc/fstab file



/dev/sda5 /media/Data ntfs defaults,umask=007,gid=46,noatime 0 0

Mounting NTFS (Windows) drive automatically in Ubuntu

Add the following line in you /etc/fstab file

/dev/sda5 /media/Data ntfs defaults,umask=007,gid=46,noatime 0 0

Wednesday, April 13, 2011

Print the Stack Trace of the Exception to log file

In Java, when an Exception occurres , the following code snippent can be used to print it in a log file


import java.io.PrintWriter;
import java.io.StringWriter;
public static String logStackTrace(Throwable t)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
exp.printStackTrace(pw);
pw.flush();
sw.flush();
nLog("exception  "+ sw.toString());
}

public void nLog(String msg) {
try {
BufferedWriter out = new
BufferedWriter(new FileWriter("/home/temp/ex.log",true));
out.write(msg+"n");
out.close();
} catch (IOException e) {
e.printStackTrace();
}

Print the Stack Trace of the Exception to log file

In Java, when an Exception occurres , the following code snippent can be used to print it in a log file


import java.io.PrintWriter;
import java.io.StringWriter;
public static String logStackTrace(Throwable t)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
exp.printStackTrace(pw);
pw.flush();
sw.flush();
nLog("exception  "+ sw.toString());
}

public void nLog(String msg) {
try {
BufferedWriter out = new
BufferedWriter(new FileWriter("/home/temp/ex.log",true));
out.write(msg+"\n");
out.close();
} catch (IOException e) {
e.printStackTrace();
}

Sunday, April 3, 2011

Quick read files in Java (Scanner)

According to me reading files in JAVA is bit more complex as compared to C or C++

I came across Java Scanner API (JDK 1.5 onwards ) which easier than than common ways how we read fie using java line by line
Here is the sample code
private static String quickReadFile(String inFileName) {
String contents = null;
try {
Scanner scanner = new Scanner(new File(inFileName)).useDelimiter("Z");
contents = scanner.next();
//System.out.println(contents);
scanner.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(ParseTagged.class.getName()).log(Level.SEVERE, null, ex);
}
return contents;
}

Quick read files in Java (Scanner)

According to me reading files in JAVA is bit more complex as compared to C or C++

I came across Java Scanner API (JDK 1.5 onwards ) which easier than than common ways how we read fie using java line by line
Here is the sample code
private static String quickReadFile(String inFileName) {
String contents = null;
try {
Scanner scanner = new Scanner(new File(inFileName)).useDelimiter("\\Z");
contents = scanner.next();
//System.out.println(contents);
scanner.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(ParseTagged.class.getName()).log(Level.SEVERE, null, ex);
}
return contents;
}

Friday, April 1, 2011

The wonders of the universe

After wonderful episodes of The wonders of the Solar System Prof. Brian Cox is back in BBC with his brand new episodes of The Wonders of the Universe.

I am very much excited to watch all the episode which not only does a great awareness of basic science among people but also tries describe complicated astronomical theories in plain English. UK residents can watch it here

http://www.youtube.com/p/ED63D891C6ECC17F?hl=en_US&fs=1

The above 3 out of 4 episodes in this season has been already aired.

The wonders of the universe

After wonderful episodes of The wonders of the Solar System Prof. Brian Cox is back in BBC with his brand new episodes of The Wonders of the Universe.

I am very much excited to watch all the episode which not only does a great awareness of basic science among people but also tries describe complicated astronomical theories in plain English. UK residents can watch it here




The above 3 out of 4 episodes in this season has been already aired.