Tuesday 9 October 2012

Difference between Carriage Return, Line Feed (New Line) and Form Feed

Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as "\r", abbreviated CR, and has ASCII value 13 or 0xD.

Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates lines (commonly confused with separating lines). This is commonly escaped as "\n", abbreviated LF or NL, and has ASCII value 10 or 0xA. CRLF (but not CRNL) is used for the pair "\r\n".

Form feed means advance downward to the next "page". It was commonly used as page separators, but now is also used as section separators. (It's uncommonly used in source code to divide logically independent functions or groups of functions.) Text editors can use this character when you "insert a page break". This is commonly escaped as "\f", abbreviated FF, and has ASCII value 12 or 0xC.
As control characters, they may be interpreted in various ways.

The most common difference (and probably the only one worth worrying about) is lines end with CRLF on Windows, NL on Unix-likes, and CR on older Macs (I believe the situation has changed somewhat with OS X to be more like Unix). Note the shift in meaning from LF to NL, for the exact same character, gives the differences between Windows and Unix. (Windows is, of course, newer than Unix, so it didn't adopt this semantic shift. I don't know the history of Macs using CR.) Many text editors can read files in any of these three formats and convert between them, but not all utilities can.
Form feed is a bit more interesting (even though less commonly used directly), and with the usual definition of page separator, it can only come between lines (e.g. after the newline sequence of NL, CRLF, or CR) or at the start or end of the file.

<br>
Assuming you mean this:
public static String newLine = System.getProperty("line.separator");
newLine is environment agnostic \r isn't.
So newLine will give you \r\n on windows but \n on another environment.
However, you shouldn't use this in a JTextArea and println will work fine with just \n on windows.
Edit now that I've seen the code and your comment

In your situation. I think you should use your own constant - \r\n
  File f = new File(strFileGenLoc);
  BufferedWriter bw = new BufferedWriter(new FileWriter(f, false));
  rs = stmt.executeQuery("select * from jpdata");
  while ( rs.next() ) {
    bw.write(rs.getString(1)==null? "":rs.getString(1));
    bw.write("\\r\\n");
  }

difference between RTGS and NEFT fund transfer

difference between RTGS and NEFT fund transfer

1. What is RTGS System?

Ans The acronym "RTGS" stands for Real Time Gross Settlement. RTGS system is a funds transfer mechanism where transfer of money takes place from one bank to another on a "real time" and on "gross" basis. This is the fastest possible money transfer system through the banking channel. Settlement in "real time" means payment transaction is not subjected to any waiting period. The transactions are settled as soon as they are processed. "Gross settlement" means the transaction is settled on one to one basis without bunching with any other transaction. Considering that money transfer takes place in the books of the Reserve Bank of India, the payment is taken as final and irrevocable.

2 How RTGS is different from Electronic Fund Transfer System (EFT) or National Electronics Funds Transfer System (NEFT)?

Ans EFT and NEFT are electronic fund transfer modes that operate on a deferred net settlement (DNS) basis which settles transactions in batches. In DNS, the settlement takes place at a particular point of time. All transactions are held up till that time. For example, NEFT settlement takes place 6 times a day during the week days (9.30 am, 10.30 am, 12.00 noon. 1.00 pm, 3.00 pm and 4.00 pm) and 3 times during Saturdays (9.30 am, 10.30 am and 12.00 noon). Any transaction initiated after a designated settlement time would have to wait till the next designated settlement time. Contrary to this, in RTGS, transactions are processed continuously throughout the RTGS business hours.

Source(s):

Reserve Bank of India
http://www.rbi.org.in/scripts/FAQView.aspx?Id=65

Monday 8 October 2012

TextBox only allows numbers/numerics

A Lot of javascript functions to assist you 

<script language="JavaScript" type="text/javascript">
function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}
 
 
                               OR


Html

<input type="text" id="numbersOnly" />

Javascript

<script language="JavaScript" type="text/javascript">
var input = document.getElementById('numbersOnly');
input.onkeydown = function(e) {
    var k = e.which;
/* numeric inputs can come from the keypad or the numeric row at the top */
    if ( (k < 48 || k > 57) && (k < 96 || k > 105)) {
        e.preventDefault();
        return false;
    }
}
</script>

                               OR
 
Html
 
<input type="text" onKeyUp="numericFilter(this);" />
 <script language="JavaScript" type="text/javascript"> 
Javascript 
 
function numericFilter(txb){
        txb.value =txb.value.replace(/[^\0-9]/ig, "");
 }
 </script>

 

textbox reads only numeric key strokes

<HTML>
<HEAD>
<TITLE>Allow Only Numbers
</HEAD>

<BODY>
<script language="JavaScript">
function onlyNumbers(evt)
{
 var e = event || evt; // for trans-browser compatibility
 var charCode = e.which || e.keyCode;

 if (charCode > 31 && (charCode < 48 || charCode > 57))
  return false;

 return true;

}
</script>
<input type="text" onkeypress="return onlyNumbers();">
</BODY>
</HTML>
Not so smart. This doesn't allow for the shift key being pressed, so allows any of !"£$%^&*() as well as any numeric.
Obviously (??) the onKeyDown etc doesnt detect Shift1 etc.
So as a validation before assigning to a numeric field then this just doesnt work.The problem with the shift key can be fixed as follows :

{

 var e = event || evt; // for trans-browser compatibility
 var charCode = e.which || e.keyCode;
 if (charCode > 31 && (charCode < 48 || charCode > 57))
  return false;
                if (e.shiftkey) return false;
 return true;
}
 The down side of this is that it efectively disables the numeric key pay because the Num Lock sets the shift key.
<HTML>
   <HEAD>
   <SCRIPT language=Javascript>
      <!--
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
      //-->
   </SCRIPT>
   </HEAD>
   <BODY>
      <INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">
   </BODY>
</HTML> 

Saturday 6 October 2012

Using Struts DOJO Tag on JSP

Using Struts DOJO Tag on JSP

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>

<sx:head />


<s:url id="Url" action="MyActionName.action" />

<sx:div id="myDiv" href="%{Url}" listenTopics="topic_name" preload="true" formId="myForm" showLoadingText="false" cssStyle=""></sx:div>

Linking CSS or JavaScrip with JSP

Linking CSS or JavaScrip with JSP

Linking StyleSheet CSS file

<link href="<s:url value="/css/style.css"/>" rel="stylesheet" type="text/css" />
{/css/style.css- this is path for css file}

 <link rel="stylesheet" type="text/css" href="styles.css">    

Linking Java Script file:

<script language="JavaScript" type="text/javascript" src="js/myFile.js"></script>

Hostel Management System

Hostel Management System

Tech:
C++
File Handling
Abstract:
Hostel Management with features like Configuring,Room Booking, Registeration e.t.c

Periodic Table Tutor

Periodic Table Tutor

Tech:
C++
Graphics Enabled
Abstract:
View and easy to Learn Periodic Table with quiz on elements and graphical representation.

Web Mart E-Shopping Website Project

Web Mart E-Shopping Website Project

Tech:
C# .Net
Web App
VS 2008
Sql Server 2005


Abstract:
Online Shopping Project Web based.


Link: http://www.mediafire.com/?dw6yc042pps1f3c

Online Exam Project

Online Exam Project

Tech:
C# .Net
Win App
VS 2008
Sql Server 2005


Abstract:
Online Examination Project with timer feature.

Link: http://www.mediafire.com/?23j1kul8ixq45ec

Executing Query from Java

Executing Query from Java



Before this you need to connect to database, refer to this post
Connection conn = null;
try{
         DbConnectionProvider dbConnectionProvider = new DbConnectionProvider();
         conn = dbConnectionProvider.connect();
         Statement stmt=conn.createStatement();
         String query = "SELECT NAME, AGE FROM DETAILS_TABLE";
                ResultSet rs = stmt.executeQuery(query);
                while (rs.next()){
                      System.out.println(rs.getString(1));
}}

how to connect java to oracle database

Connect Java to Oracle Database


package com.action.dbConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DbConnectionProvider {
      String serverName = "119.45.2.23";
      String sid = "xyz";     // String sid given by Oracle
      String username = "uid";
      String password = "pwd";
      String driverName = "oracle.jdbc.driver.OracleDriver";
      String portNumber = "2008";
      Connection connection = null;
     
      public Connection connect() {
            try {
System.out.println("Inside class DbConnectionProvider, Method connect()");
                  // Load the JDBC driver
                   Class.forName(driverName);
                  // Create a connection to the database
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
connection = DriverManager.getConnection(url, username, password);
            } catch (ClassNotFoundException e) {
                // Could not find the database driver
                  System.out.println("Could not find the database driver");
                  e.printStackTrace();
            } catch (SQLException e) {
                // Could not connect to the database
                  System.out.println("Could not connect to the database");
            } finally {
                 
            }
            return connection;
      }