This is the most powerful and stable way to download Google Book. You can easily download any book from books.google.com using Greasemonkey script. Just follow the simple steps below.
1 This hack only works with firefox browser. Make sure you install firefox browser.
2 Now install Greasemonkey Script
3.restart firefox
3 then install Google book downloader userscript.
4 Install Flashgot to firefox browser
5. restart your firefox browser.
6 Search any book on books.google.com and you’ll notice a download button at the sidebar as shown in screenshot.
7. Click the download button to download the images of each. Select the pages you wish to download and then right click and select FlashGot Selection to download the selected pages.
8. use igame to pdf converter to convert all into single pdf file
9.Njoy..
Wednesday, April 27, 2011
Sending Automated email in JSP/Java
This summary is not available. Please
click here to view the post.
Wednesday, April 20, 2011
Upload files using jsp
<%@ page import="java.io.*" %>
<%
String contentType = request.getContentType();
System.out.println("Content type is :: " +contentType);
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))
{
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength)
{
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
//out.print("FileName:" + saveFile.toString());
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//out.print("FileName:" + saveFile.toString());
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
//out.print("FileName:" + saveFile.toString());
//out.print(dataBytes);
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
//out.println(boundary);
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
saveFile = "D:\\java\tomcat5\\webapps\\ROOT\\images\\" + saveFile;
FileOutputStream fileOut = new FileOutputStream(saveFile);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
out.println("File saved as " +saveFile);
}
%>
Read and write file in jsp
<%@ page import="java.io.*" %>
Read write file JSP
<%
String fileName=getServletContext().getRealPath("jsp.txt");
File f=new File(fileName);
InputStream in = new FileInputStream(f);
BufferedInputStream bin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(bin);
StringBuffer sb=new StringBuffer();
while(din.available()>0)
{
sb.append(din.readLine());
}
try {
PrintWriter pw = new PrintWriter(new FileOutputStream("c:/file.txt"));// save file
pw.println(sb.toString());
pw.close();
} catch(IOException e) {
e.getMessage();
}
in.close();
bin.close();
din.close();
%>
Successfully write file
<%
String fileName=getServletContext().getRealPath("jsp.txt");
File f=new File(fileName);
InputStream in = new FileInputStream(f);
BufferedInputStream bin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(bin);
StringBuffer sb=new StringBuffer();
while(din.available()>0)
{
sb.append(din.readLine());
}
try {
PrintWriter pw = new PrintWriter(new FileOutputStream("c:/file.txt"));// save file
pw.println(sb.toString());
pw.close();
} catch(IOException e) {
e.getMessage();
}
in.close();
bin.close();
din.close();
%>
Successfully write file
Tuesday, April 19, 2011
sqlite.JDBC Sample code..
//run by
//java -classpath ".;sqlite-jdbc-3.5.7.jar" Sample
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
class Test
{
String path="jdbc:sqlite:C:/Documents and Settings/Dipankar/Desktop/Dropbox/mq/sample.db";
//=======================logic strat from here add user..===================[DONE]
public void adduser(String username,String filename,String content)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
//auto calculete id
int uid=0;
try{
connection = DriverManager.getConnection(path);
Statement statement1 = connection.createStatement();
ResultSet rs1=statement1.executeQuery("select count(*) from userinfo");
uid=rs1.getInt(1)+1;
}
catch(Exception e)
{
System.out.println("Error here");
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
System.out.println("insert into userinfo values("+uid+",'"+username+"','"+filename+"','"+content+"')");
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
statement.executeUpdate("insert into userinfo values("+uid+",'"+username+"','"+filename+"','"+content+"')");
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END==================================================================
//=======================logic strat from here view user..===================[DONE]
public void showinfo(int userid)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from userinfo where userid="+userid);
while(rs.next())
{
// read the result set
System.out.println("id = " + rs.getInt("userid"));
System.out.println("name = " + rs.getString("username"));
System.out.println("finemane = " + rs.getString("filename"));
System.out.println("file conetct = " + rs.getString("filecontent"));
}
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END===================================================================
//=======================logic strat from here view user..===================[DONE]
public void removeuser(int userid)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
statement.executeUpdate("delete from userinfo where userid="+userid);
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END===================================================================
}
public class TestDB
{
public static void main(String[] args) throws ClassNotFoundException
{
// load the sqlite-JDBC driver using the current class loader
Class.forName("org.sqlite.JDBC");
Test x= new Test();
x.showinfo(0);
}
}
//java -classpath ".;sqlite-jdbc-3.5.7.jar" Sample
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
class Test
{
String path="jdbc:sqlite:C:/Documents and Settings/Dipankar/Desktop/Dropbox/mq/sample.db";
//=======================logic strat from here add user..===================[DONE]
public void adduser(String username,String filename,String content)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
//auto calculete id
int uid=0;
try{
connection = DriverManager.getConnection(path);
Statement statement1 = connection.createStatement();
ResultSet rs1=statement1.executeQuery("select count(*) from userinfo");
uid=rs1.getInt(1)+1;
}
catch(Exception e)
{
System.out.println("Error here");
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
System.out.println("insert into userinfo values("+uid+",'"+username+"','"+filename+"','"+content+"')");
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
statement.executeUpdate("insert into userinfo values("+uid+",'"+username+"','"+filename+"','"+content+"')");
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END==================================================================
//=======================logic strat from here view user..===================[DONE]
public void showinfo(int userid)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select * from userinfo where userid="+userid);
while(rs.next())
{
// read the result set
System.out.println("id = " + rs.getInt("userid"));
System.out.println("name = " + rs.getString("username"));
System.out.println("finemane = " + rs.getString("filename"));
System.out.println("file conetct = " + rs.getString("filecontent"));
}
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END===================================================================
//=======================logic strat from here view user..===================[DONE]
public void removeuser(int userid)
{
// load the sqlite-JDBC driver using the current class loader
Connection connection = null;
try
{
connection = DriverManager.getConnection(path);
Statement statement = connection.createStatement();
statement.executeUpdate("delete from userinfo where userid="+userid);
}
catch(SQLException e)
{
// if the error message is "out of memory",
// it probably means no database file is found
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection != null)
connection.close();
}
catch(SQLException e)
{
// connection close failed.
System.err.println(e);
}
}
}
//=======================END===================================================================
}
public class TestDB
{
public static void main(String[] args) throws ClassNotFoundException
{
// load the sqlite-JDBC driver using the current class loader
Class.forName("org.sqlite.JDBC");
Test x= new Test();
x.showinfo(0);
}
}
Monday, April 18, 2011
Java Fille I/0
import java.io.*;
public class FileReader {
public static void main (String[] args) {
System.out.println ("Program to demonstrate reading from a file");
BufferedReader br = null;
String fileName = args[0];
// If an error occurs, go to the "catch" block
try {
// FileInputStream fis = new FileInputStream (fileName);
FileReader fis = new FileReader (fileName);
br = new BufferedReader (fis);
// continue to read lines while there are still some left to read
while ( br.ready() ) {
System.out.println (br.readLine());
}
// Close the input stream
br.close();
} catch (Exception e) {
// Handle any error in opening the file
System.err.println("File input error");
}
} // End of main method
} // End of the class FileReader
Monday, March 21, 2011
Installing Flash Player Plugin on Firefox without having Administrator Access or Premissions
In the cybercafe in our hostel , i face this problem
in CC , mozila firefox is install in each computer but flash player was not install . as admin permission is not given to us, we cannot install flash player their. they make this thing to restrict from viewing Youtube video in CC.
you cannot install adobe flash player without admin permission.
but there is an alternative way to add flash plugin in firefox, shown step by step as below
it does not require any Admin permission,
This is how I managed to install it without administrator permissions:
step 1: Download the XPI archive of the Flash Player Plugin to your hard disk (right click on the download link then "Save link as.."). XPI archives are only ZIP files containing the files used by the plugins. A of the plugin is also available http://fpdownload.macromedia.com/get/flashplayer/xpi/current/flashplayer-win.xpi
So you can safely rename the file you just downloaded, called flashplayer-win.xpi, into flashplayer-win.zip (you are changing its extension from .xpi to .zip)
step 2: Extract the files in the archive. You can use any program capable of opening .zip files (WinZip, WinRAR or the free and great 7-zip). There are also websites which can uncompress archives: wobzip.org.
step 3:
Copy the files flashplayer.xpt and NPSWF32.dll to %APPDATA%\Mozilla\Plugins\
%APPDATA% is not a real folder. It's an alias. By inserting it in your windows explorer address bar, you'll be redirected to the real folder which holds your applications profiles and settings. The location of this folder depends on various setting that's why we need the alias and not an absolute path.
You can open this folder simply choosing "Start → Run → Type in %APPDATA% → OK".
In case you don't have a Plugins folder you can create one and place your files there.
step 4:
Restart Firefox
last step:..
Enjoy your flash websites!
in CC , mozila firefox is install in each computer but flash player was not install . as admin permission is not given to us, we cannot install flash player their. they make this thing to restrict from viewing Youtube video in CC.
you cannot install adobe flash player without admin permission.
but there is an alternative way to add flash plugin in firefox, shown step by step as below
it does not require any Admin permission,
This is how I managed to install it without administrator permissions:
step 1: Download the XPI archive of the Flash Player Plugin to your hard disk (right click on the download link then "Save link as.."). XPI archives are only ZIP files containing the files used by the plugins. A of the plugin is also available http://fpdownload.macromedia.com/get/flashplayer/xpi/current/flashplayer-win.xpi
So you can safely rename the file you just downloaded, called flashplayer-win.xpi, into flashplayer-win.zip (you are changing its extension from .xpi to .zip)
step 2: Extract the files in the archive. You can use any program capable of opening .zip files (WinZip, WinRAR or the free and great 7-zip). There are also websites which can uncompress archives: wobzip.org.
step 3:
Copy the files flashplayer.xpt and NPSWF32.dll to %APPDATA%\Mozilla\Plugins\
%APPDATA% is not a real folder. It's an alias. By inserting it in your windows explorer address bar, you'll be redirected to the real folder which holds your applications profiles and settings. The location of this folder depends on various setting that's why we need the alias and not an absolute path.
You can open this folder simply choosing "Start → Run → Type in %APPDATA% → OK".
In case you don't have a Plugins folder you can create one and place your files there.
step 4:
Restart Firefox
last step:..
Enjoy your flash websites!
Subscribe to:
Posts (Atom)