We can read paragraphs in a file by reading it in a string and then spilting based on "\r" pattern. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This is Line 5 This is Line 6 This is Line 7 This is Line 8 This is Line 9 This is Line 10Tester.javaimport java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Tester { public static void main(String args[]) throws IOException { FileUtil fileUtil = ... Read More
We can read characters in a file using BufferedReader class of Java. See the example below −ExampleConsider the following text file in the classpath.test.txtThis is Line 1 This is Line 2 This is Line 3 This is Line 4 This is Line 5 This is Line 6 This is Line 7 This is Line 8 This is Line 9 This is Line 10Tester.javaimport java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class Tester { private static final String FILE_PATH = "data.txt"; public static void main(String args[]) throws IOException { ... Read More
You have the following Operators that can be used to define restrictions
Database Management System is quite useful compared to the file based management system. However, it does have some disadvantages. Some of those are as follows −More CostlyCreating and managing a database is quite costly. High cost software and hardware is required for the database. Also highly trained staff is required to handle the database and it also needs continuous maintenance. All of these ends up making a database quite a costly venture.High ComplexityA Database Management System is quite complex as it involves creating, modifying and editing a database. Consequently, the people who handle a database or work with it need ... Read More
The systems that are used to organize and maintain data files are known as file based data systems. These file systems are used to handle a single or multiple files and are not very efficient. FunctionalitiesThe functionalities of a File-based Data Management System are as follows −A file based system helps in basic data management for any user.The data stored in the file based system should remain consistent. Any transactions done in the file based system should not alter the consistency property. The file based system should not allow any illegal or potentially hazardous operations to occur on the data.The file based ... Read More
A database is a collection of data, usually stored in electronic form. A database is typically designed so that it is easy to store and access information.A good database is crucial to any company or organisation. This is because the database stores all the pertinent details about the company such as employee records, transactional records, salary details etc.The various reasons a database is important are −Manages large amounts of dataA database stores and manages a large amount of data on a daily basis. This would not be possible using any other tool such as a spreadsheet as they would simply ... Read More
Object oriented data model is based upon real world situations. These situations are represented as objects, with different attributes. All these object have multiple relationships between them.Elements of Object oriented data modelObjectsThe real world entities and situations are represented as objects in the Object oriented database model.Attributes and MethodEvery object has certain characteristics. These are represented using Attributes. The behaviour of the objects is represented using Methods.ClassSimilar attributes and methods are grouped together using a class. An object can be called as an instance of the class.InheritanceA new class can be derived from the original class. The derived class contains ... Read More
To check if event exists on element in jQuery, check for the existing events on the element. Here, I have set the div − This is demo text. Click here! When you click div, then the alert generates which I have set using the div id:$("#demo").click(function() { alert("Does event exists? - "+hasEvents); });You can try to run the following code to check if event exists −ExampleLive Demo $(document).ready(function(){ $("#demo").click(function() { alert("Does event exists? - "+hasEvents); }); var events = $._data(document.getElementById('demo'), "events"); var hasEvents = (events != null); }); This is demo text. Click here!
Following example demonstrates how to check whether the date is in a proper format or not using matches method of String class.ExampleLive Demopublic class Main { public static void main(String[] argv) { boolean isDate = false; String date1 = "8-05-1988"; String date2 = "08/04/1987"; String datePattern = "\d{1, 2}-\d{1, 2}-\d{4}"; isDate = date1.matches(datePattern); System.out.println("Date :"+ date1+": matches with the this date Pattern:"+datePattern+"Ans:"+isDate); isDate = date2.matches(datePattern); System.out.println("Date :"+ date2+": matches with the this date ... Read More
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.ExampleLive Demoimport java.util.*; import java.text.*; public class DateDemo { public static void main(String args[]) { Date dNow = new Date( ); SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); System.out.println("Current Date: " + ft.format(dNow)); } }This will produce the following result −OutputCurrent Date: Sun 2004.07.18 at 04:14:09 PM PDTSimple DateFormat ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP