Showing posts with label crash course. Show all posts
Showing posts with label crash course. Show all posts

Monday, July 22, 2013

Windows command promt in 20 minutes : Crash Course

Windows Command Prompt in 20 Minutes

What is Command Prompt?

Command Prompt (executable name cmd.exe) is the Microsoft-supplied command-line interpreter on OS/2, Windows CE and on Windows NT-based operating systems (including Windows 2000, XP, Vista, 7, 8, Server 2003, Server 2008,Server 2008 R2 and Server 2012). It is the analog of COMMAND.COM in MS-DOS and Windows 9x systems (where it is called "MS-DOS Prompt"), or of the Unix shells used on Unix-like systems.
Source : Wikipedia.com

Advantages and Disadvantages of Command Pompt

Advantages:

·       Traditional operating system so less memory used.
·       Control every aspect of your computer.
·       It is fast as compared to other operating system.
·       Good for speed if you have a slow computer.

Disadvantages
·       Not User Friendly
·       Not GUI (Graphic User Interface).
·       Many of the advantages are mainly for Linux, not so much for Windows.

launch Command Prompt


Press Start -> Run and type cmd in the box.
Or
You can search cmd in the windows 7 start menu search bar and then click “cmd.exe”
It has a  black terminal window.
The command prompt should look something
like:
C:\>
Here you can type you commands.
Command prompt it NOT CASE SENSITIVE
It does not care if the command is of upper-case or lower case.
The “c:\>” this shows the location where you are typing your command currently you are in the c: drive .

Some of the command commands :

exit: Exit the Command Prompt program and close the terminal window.
C:\>exit [Enter]

Working with Files and Directories

dir: To view the contents of a directory, type dir. This command will list all the files and directories within the current directory.
Same as clicking the c: drive for seeing what folders and files it contains
C:\>dir
 Volume in drive C has no label.
 Volume Serial Number is EE09-D4F4

 Directory of C:\

03/06/2013  11:39 PM             3,072 ads_err.adi
03/06/2013  11:39 PM             4,559 ads_err.adm
03/06/2013  11:44 PM            13,785 ads_err.adt
06/11/2012  08:49 PM    <DIR>          ATI
06/11/2009  03:12 AM                24 autoexec.bat
06/11/2009  03:12 AM                10 config.sys
06/28/2013  05:49 PM                 0 END
06/23/2011  08:51 AM     2,581,336,064 F.3.A.R-Black_Box.iso
07/14/2009  08:07 AM    <DIR>          PerfLogs
07/16/2013  05:39 PM    <DIR>          Program Files
05/15/2013  08:12 PM                43 Prova.txt
06/14/2012  11:31 PM             2,210 shared.log
05/15/2013  09:15 PM    <DIR>          temp
06/11/2012  09:02 PM    <DIR>          Users
07/15/2013  11:17 AM    <DIR>          Windows
               9 File(s)  2,581,359,767 bytes
               6 Dir(s)  91,985,027,072 bytes free

Cd : Used to create directory or to move into a directory.
 It is frequently useful to know in which directory you are currently working. In order to find out, type
cd at the command prompt.
C:\> cd
C:\
To change directories, use the cd command with the name of a directory.
C:\> cd temp
Now, the command prompt will be:
C:\temp>
To see what is in this directory type:
C:\temp>dir
 Volume in drive C has no label.
 Volume Serial Number is EE09-D4F4

 Directory of C:\temp

05/15/2013  09:15 PM    <DIR>          .
05/15/2013  09:15 PM    <DIR>          ..
05/17/2013  01:07 AM               112 Logfile.xml
               1 File(s)            112 bytes
               2 Dir(s)  91,985,022,976 bytes free
To return to the previous directory, use the cd command, but this time followed by a space and two periods.
C:\temp> cd ..
C:\>

mkdir: To create a new directory, use the command mkdir. The following command creates a directory
named hello, which you can use to to store all of your files associated with the Hello World assignment.
C:\temp> mkdir good
To see that it actually worked, use the dir command.
C:\temp>dir
 Volume in drive C has no label.
 Volume Serial Number is EE09-D4F4

 Directory of C:\temp

07/22/2013  10:50 AM    <DIR>          .
07/22/2013  10:50 AM    <DIR>          ..
07/22/2013  10:50 AM    <DIR>          good
05/17/2013  01:07 AM               112 Logfile.xml
               1 File(s)            112 bytes
               3 Dir(s)  91,985,022,976 bytes free

move: Now, move the two files abc.text and readme.txt into the good directory using the move command.
C:\temp> move abc.txt hello
C:\temp> move readme.txt hello
C:\temp> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/11/2005 02:53 PM DIR hello
0 File(s) 0 bytes
3 Dir(s)
The two files are no longer visible from the current directory.
To access the two files, change directories with the cd command. Then use the dir command to see what
is in this new directory.
C:\temp> cd hello
C:\temp\hello> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\temp\hello
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 abc.java
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
You can also use move to rename a file. Simply specify a new filename instead of a directory name.
Suppose you accidentally messed up the upper and lower case and had saved abc.txt as
abc.txt. Use two move commands to fix it.
C:\temp\good> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\temp\good
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 abc.txt
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
C:\ temp\good > move abc.txt temp.java
C:\ temp\good > move temp.txt abc.java
C:\ temp\good > dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\ temp\good
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 abc.txt
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
2 Dir(s)
It takes two moves because Windows won't let you move to an already existing filename and, to Windows, abc.txt is the same as Abc.txt.

Copy : To make a copy of a file, use the copy command. The following command creates a backup copy of our Abc.txt program. This is especially useful when you modify a working program, but might want to revert back to the original version if your modifications don't succeed.
C:\temp\good> copy Abc.txt HelloWorld.bak
C:\temp\good> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\temp\good
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 Abc.txt
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
3 Dir(s)

del: Subsequently, you might want to clean up useless files. The del command deletes a file.
C:\temp\good> del HelloWorld.bak
C:\temp\good> dir
Volume in drive C has no label.
Volume Serial Number is C8C7-BDCD
Directory of C:\introcs
02/10/2005 08:59 PM DIR .
02/10/2005 08:59 PM DIR ..
02/03/2005 11:53 PM 126 Abc.txt
01/17/2005 01:16 AM 256 readme.txt
2 File(s) 382 bytes
3 Dir(s)

WARNING: When you revise a file in jEdit, the jEdit program will automatically save a backup copy of your original file in the same directory. The name of the backup file will be the name of the original file with a ~ at the end. When you submit your program be careful to submit Abc.txt and not Abc.txt~ which is an old version of the file and has the wrong name.

wildcards: You can also apply the copy, del, and move commands to several files (or directories) at once. To create a new directory called loops, and copy all of the files in the hello directory
C:\temp\good\ into this newly created directory type:
C:\introcs> mkdir loops
C:\introcs> copy c:\temp\good\* loops
Here the * matches all files in the C:\temp\good directory. It copies them to your newly created loops directory.

Wednesday, July 17, 2013

Alternatives to disk volume defragmentation

Why do we need to Defragment  ... ?


Use reuse of files , deletion, modification creates fragments in the system . which makes the system slower..

Defragmentation ::
n the maintenance of file systems, defragmentation is a process that reduces the amount of fragmentation. It does this by physically organizing the contents of the mass storage device used to store files into the smallest number of contiguous regions (fragments). It also attempts to create larger regions of free space using compaction to impede the return of fragmentation. Some defragmentation utilities try to keep smaller files within a single directory together, as they are often accessed in sequence.
Fragmentation ::

Fragmentation occurs when the file system cannot or will not allocate enough contiguous space to store a complete file as a unit, but instead puts parts of it in gaps between other files (usually those gaps exist because they formerly held a file that the operating system has subsequently deleted or because the file system allocated excess space for the file in the first place). Larger files and greater numbers of files also contribute to fragmentation and consequent performance loss. Defragmentation attempts to alleviate these problem.


Common countermeasures ::

Partitioning ::
A common strategy to optimize defragmentation and to reduce the impact of fragmentation is to partition the hard disk(s) in a way that separates partitions of the file system that experience many more reads than writes from the more volatile zones where files are created and deleted frequently.
Offline defragmentation
The presence of immovable system files, especially a swap file, can impede defragmentation. These files can be safely moved when the operating system is not in use.



Some useful Terms :
You’ll need administrator rights to run the tool. So from the start menu, click All Programs > Accessories. Right-click on command prompt and select run as administrator.

How to defragment using Windows 7 Command Line

The defrag.exe command syntax initially looks a bit confusing:

Defrag <volume(s)> | /C | /E <volumes> [/A | /X | /T] [/H] [/M] [/U] [/V]

For help in command line type “ defrag ?”

Command Options :-

- A Display a fragmentation analysis report for the specified volume without defragmenting it.
- C Defragment all local volumes on the computer
- E Defragment all local volumes on the computer except those specified.
- H Run the operation at normal priority instead of the default low priority. Specify this option if a computer is not otherwise in use.
- M Run the operation on each volume in parallel. This is used primarily for SCSI or SATA type disks rather than the typical IDE.
- T Track an operation already in progress on the specified volume.
- U Print the progress of the operation on the screen.
- V Verbose mode. Provides additional detail and statistics.
- X Perform free-space consolidation. Free-space consolidation is useful if you need to shrink a volume, and it can reduce fragmentation of future files.


Methods  to Disk Volume Defragmentation

Method #1 – Using the Built-In Windows 7 Defrag Tool

First, let me cover the internal Windows 7 tool that allows you to defrag windows 7 hard disks. This tool is a lot better than the one available in Windows Vista (at least in its design and in the way it works) but the built-in tool lacks many user options and that is why I offer Method #2, below.

To run the Windows 7 built-in defragmenting tool follow these steps:
Open Windows Explorer. Right-click the desired partition and select Properties.
In the Tools tab, click on Defragment Now.
For those that feel that the built-in Windows 7 defrag tool lacks both in functionality and in UI, there are 3rd-party tools that may do a better job. One of them is Auslogic Disk Defrag.
Auslogic Disk Defrag is free for personal non-commercial use.

Method #3 – Using the Command line to defragment

Defrag <volume(s)> | /C | /E <volumes> [/A | /X | /T] [/H] [/M] [/U] [/V]




Tuesday, July 16, 2013

Learn C# programming language : Lesson 001 Introduction

Introduction to the C# language and .Net Framework

C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .net framework. You can use C# to crate traditional windows client applications, XML web services , distributed components, client-server applications, database applications, and integrated debugger, and many other tools to make it easier to develop applications based on version 4.0 of the C#  language and version 4.0 of the .NET framework.

C# language

C# syntax is highly expressive , yet it is also simple and easy to learn. The curly- brace syntax of C# will be instantly recognizable to anyone familiar with C, C++ or java. Developers who know any of these languages are typical bale to begin t work productively in C# within a very short time C# syntax simplifies many of the complexities of C++ and provides powerful features such an null-able value types, enumerations, delegates lamda expressions and direct memory access, which are not found in java. C# supports generic methods and types which provide increased type safety and performance and iterators, which enables implementer of collection classes to define custom iteration behavior that are simple to use by client code. Language Integrated Query (LINQ) expressions make the strongly typed query a first class language construct.

An Object Oriented language C# supports the concepts of encapsulation, inheritance and polymorphic, All variables and methods, including the Main method , the application's entry point , are encapsulated within class definitions, A class may inherit directly from one parent class, but it may implement any number of interface methods that override virtual methods in a parent class require the override keyword as a way to avoid accidental redefinition . 

There are no header files, and no requirement that methods and types be declared in a particular order. A C# file may define any number of classes, structs , interfaces , and events.

C#.net having code Best Security Because
  1. it is case sensitive
  2. Every statement ends with terminator i.e. semicolon(;)
  3. Every Block quoted by curly Braces ({})
  4. It is purely Maintain type Conversion.

Sunday, June 16, 2013

Programming in C - 2. Input/Output Operations

C language does not have any built-in Input- Output (I/O) statements as a part of its syntax.
All the Input/Output operations are carried out through functions calls such as printf() and scanf()


scanf() 



  • General purpose console input function. Also used to input a data line containing mixed mode data.
  • syntax : scanf ("format specifier", variable_list); // end with semi-colon and case-sensitive.
  • 'format specifier' specifies the field format in which the data has to be entered.
  • 'variable list' specifies the address of the location where the data is stored.
  • use '%' before format sepecifier and '&' before a variable name
Format Specifier
  • It contains specifications for the interpretation of input data.
  • '%' conversion character.
  • list of format specifier
    • %c To read a single character
    • %d To read a decimal integer
    • %e To read a floating point value
    • %f  To read a floating point number
    • %g To read a floating point value
    • %o to read an octal value
    • %x To read an Hexadecimal value
    • %s To read a String
    • %u To read an unsigned integer
  • For reading a string 
    • scanf("%s", &st); // st contains the string value
  • For reading two values
    • scanf("%d,%d",&a,&b);\
  • Features :
    • format specification and variable list must correctly match the same order
    • The format specifier must be separated by space or comma and vairable list by comma
    • use of invalid match between format specifier and variable list will make the scanf() to terminate the reading of data

printf()

  • syntax : printf ( " format specifier ", variable list);
  • never takes the print to the new line so we use '\n' for a new line
  • eg : printf(" no of chocolates = %d \n no of sweets = %d",&a,&b); // ouput : no of chocolates = 12 [next line ] no of sweets = 13 // where a = 12 and b =13
  • list of escape sequences like \n 
    • \b     back space
    • \f      Form feed
    • \n     New line
    • \r     Carriage return
    • \t     Horizontal tab
    • \"     Double quote mark
    • \'     single quote mark
    • \0    null
    • \\     Back slash
    • \v    Vertical tab
    • \a    Alert ( rings a bell)
    • \o    Octal constant
    • \x     Hexadecimal constant

Sample Program :


First you need :
Compiler :
online compiler : codepad.org
offline compiler : http://edn.embarcadero.com/article/20633 (borlan c++ compiler)
                           http://www.digitalmars.com/ (digital mars c compiler)

01 #include <stdio.h> // imports the header file stdio.h which contains the definitions of scanf() and printf()
                                     functions.
02 void main() // execution of the program begins in the main() function
03 {
04       printf(" Hello world ");
05 } // main() ends here

output : Hello world 



Next Article : Programming in C - 3. Control Statements and Arrays

Tuesday, December 18, 2012

Java Tutorial : Crash Course


Java Tutorial 

Java is:
platform independent programming language
similar to C++ in syntax


Interesting features:
  • automatic type checking,
  • automatic garbage collection,
  • simplifies pointers; 
  • no directly accessible pointer to memory, 
  • simplified network access, 
  • multi-threading!

How it works .......
Platform Independent Why ?
Only depends on the Java Virtual Machine (JVM),
code is compiled to bytecode, which is interpreted by the resident JVM,
JIT (just in time) compilers attempt to increase speed.
Security:
Pointer denial - reduces chances of virulent programs corrupting host,
Applets even more restricted -
May not run local executables,
Read or write to local file system,
Communicate with any server other than the originating server.
Object-Oriented
Java supports OOD
  • Polymorphism
  • Inheritance
  • Encapsulation

Java programs contain nothing but definitions and instantiations of classes
Everything is encapsulated in a class!
Java Advantages
  • Portable - Write Once, Run Anywhere
  • Security has been well thought through
  • Robust memory management
  • Designed for network programming
  • Multi-threaded (multiple simultaneous tasks)
  • Dynamic & extensible (loads of libraries)


Basic Java Syntax :

Primitive Types and Variables :
boolean, char, byte, short, int, long, float, double etc.
These basic (or primitive) types are the only types that are not objects (due to performance issues).
This means that you don’t use the new operator to create a primitive variable.
Declaring primitive variables:
float initVal;
int retVal, index = 2;
double gamma = 1.2, brightness
boolean valueOk = false;

Initialisation :
If no value is assigned prior to use, then the compiler will give an error
Java sets primitive variables to zero or false in the case of a boolean variable
All object references are initially set to null
An array of anything is an object
Set to null on declaration
Elements to zero false or null on creation

Declarations :
int index = 1.2;   // compiler error
boolean retOk = 1;  // compiler error
double fiveFourths = 5 / 4;   // no error!
float ratio = 5.8f;  // correct
double fiveFourths = 5.0 / 4.0;  // correct
1.2f is a float value accurate to 7 decimal places.
1.2 is a double value accurate to 15 decimal places.
Assignment
All Java assignments are right associative
  int a = 1, b = 2, c = 5
  a = b = c
   System.out.print(
  “a= “ + a + “b= “ + b + “c= “ + c)
What is the value of a, b & c
Done right to left: a = (b = c);
Basic Mathematical Operators
* / % + - are the mathematical operators
* / % have a higher precedence than + or -
double myVal = a + b % d – c * d / b;
Is the same as:
double myVal = (a + (b % d)) –
    ((c * d) / b);

Statements & Blocks :
A simple statement is a command terminated by a semi-colon:
  name = “Fred”;
A block is a compound statement enclosed in curly brackets:
  {
  name1 = “Fred”; name2 = “Bill”;
  }
Blocks may contain other blocks

Flow of Control :
Java executes one statement after the other in the order they are written
Many Java statements are flow control statements:
Alternation:   if, if else, switch
Looping:  for, while, do while
Escapes:  break, continue, return
If – The Conditional Statement
The if statement evaluates an expression and if that evaluation is true then the specified action is taken
if ( x < 10 ) x = 10;
If the value of x is less than 10, make x equal to 10
It could have been written:
if ( x < 10 )
x = 10;
Or, alternatively:
if ( x < 10 ) { x = 10; }

Relational Operators :
  • ==  Equal 
  • !=  Not equal
  • >=  Greater than or equal
  • <=  Less than or equal
  • >  Greater than
  • <  Less than

If… else
The if … else statement evaluates an expression and performs one action if that evaluation is true or a different action if it is false.
   if (x != oldx) {
  System.out.print(“x was changed”);
}
else {
  System.out.print(“x is unchanged”);
}
Nested if … else
if ( myVal > 100 ) {
  if ( remainderOn == true) {
    myVal = mVal % 100;
  }
  else {
  myVal = myVal / 100.0;
  }
}
else
{
  System.out.print(“myVal is in range”);
}
else if
Useful for choosing between alternatives:
if ( n == 1 ) {
  // execute code block #1
}
else if ( j == 2 ) {
  // execute code block #2
}
else {
  // if all previous tests have failed, execute code block #3
}

CORRECT!
if( i == j ) {
  if ( j == k )
  System.out.print(
      “i equals k”);
}
else
  System.out.print(“i is not equal to j”);  // Correct!
The switch Statement
switch ( n ) {
  case 1:
  // execute code block #1
  break;
  case 2:
  // execute code block #2
  break;
  default:
  // if all previous tests fail then          //execute code block #4
  break;
}
The for loop
Loop n times
for ( i = 0; i < n; n++ ) {
  // this code body will execute n times
  // ifrom  0 to n-1
}
Nested for:
for ( j = 0; j < 10; j++ ) {
  for ( i = 0; i < 20; i++ ){
  // this code body will execute 200 times
  }
}
 
while loops
while(response == 1) {
  System.out.print( “ID =” + userID[n]);
  n++;
  response = readInt( “Enter “);
}
do {… } while loops
do {
  System.out.print( “ID =” + userID[n] );
  n++;
  response = readInt( “Enter ” );
}while (response == 1);
Break
A break statement causes an  exit from the innermost containing while, do, for or switch statement.
for ( int i = 0; i < maxID, i++ ) {
  if ( userID[i] == targetID ) {
  index = i;
  break;
  }
}  // program jumps here after break
Continue
Can only be used with while, do or for.
The continue statement causes the innermost loop to start the next iteration immediately
for ( int i = 0; i < maxID; i++ ) {
  if ( userID[i] != -1 ) continue;
  System.out.print( “UserID ” + i + “ :” +     userID);
}

Arrays
Am array is a list of similar things
An array has a fixed:
name
type
length
These must be declared when the array is created.
Arrays sizes cannot be changed during the execution of the code
Declaring Arrays
int myArray[];
declares myArray to be an array of integers
myArray = new int[8];
sets up 8 integer-sized spaces in memory, labelled myArray[0] to myArray[7]
int myArray[] = new int[8];
combines the two statements in one line
Assigning Values
refer to the array elements by index to store values in them.
myArray[0] = 3;
myArray[1] = 6;
myArray[2] = 3;   ...
can create and initialise in one step:
int myArray[] = {3, 6, 3, 1, 6, 3, 4, 1};
Iterating Through Arrays
for loops are useful when dealing with arrays:
for (int i = 0; i < myArray.length; i++) {
  myArray[i] = getsomevalue();
}
Arrays of Objects
So far we have looked at an array of primitive types.
integers
could also use doubles, floats, characters…
Often want to have an array of objects
Students, Books, Loans ……
Need to follow 3 steps.
Declaring the Array
1. Declare the array
  private Student studentList[];
this declares studentList
2 .Create the array
  studentList = new Student[10];
this sets up 10 spaces in memory that can hold references to Student objects
3. Create Student objects and add them to the array: studentList[0] = new Student("george", "Computing");

Java Methods & Classes
Classes ARE Object Definitions
OOP - object oriented programming
code built from objects
Java these are called classes
Each class definition is coded in a separate .java file
Name of the object must match the class/object name    

The three principles of OOP
Encapsulation
Objects hide their functions (methods) and data (instance variables)
Inheritance
Each subclass inherits all variables of its superclass
Polymorphism
Interface same despite different data types

Methods :
A method is a named sequence of code that can be invoked by other Java code.
A method takes some parameters, performs some computations and then optionally returns a value (or object).
Methods can be used as part of an expression statement.
 
public float convertCelsius(float tempC) {
  return( ((tempC * 9.0f) / 5.0f) + 32.0 );
  }
Method Signatures
A method signature specifies:
The name of the method.
The type and name of each parameter.
The type of the value (or object) returned by the method.
The checked exceptions thrown by the method.
Various method modifiers.
modifiers type name ( parameter list ) [throws exceptions ]
public float convertCelsius (float tCelsius ) {}
public boolean setUserInfo ( int i, int j, String name ) throws IndexOutOfBoundsException {}
Public/private
Methods/data may be declared public or private meaning they may or may not be accessed by code in other classes …
Good practice:
keep data private
keep most methods private
well-defined interface between classes - helps to eliminate errors
Using objects
Here, code in one class creates an instance of another class and does something with it …
Fruit plum=new Fruit();
int cals;
cals = plum.total_calories();
Dot operator allows you to access (public) data/methods inside Fruit class
Constructors
The line
plum = new Fruit();
invokes a constructor method with which you can set the initial data of an object
You may choose several different type of constructor with different argument lists
 eg Fruit(), Fruit(a) ...
Overloading
Can have several versions of a method in class with different types/numbers of arguments
  Fruit() {grams=50;}
    Fruit(a,b) { grams=a; cals_per_gram=b;}
By looking at arguments Java decides which version to use
Java Development Kit
javac - The Java Compiler
java -   The Java Interpreter
jdb -     The Java Debugger
appletviewer -Tool to run the applets
javap - to print the Java bytecodes
javaprof - Java profiler
javadoc - documentation generator
javah - creates C header files
Stream Manipulation
Streams and I/O
basic classes for file IO
FileInputStream, for reading from a file
FileOutputStream, for writing to a file
Example:
Open a file "myfile.txt" for reading
FileInputStream fis = new FileInputStream("myfile.txt");
Open a file "outfile.txt" for writing
FileOutputStream fos = new FileOutputStream ("myfile.txt");

General IO stream manipulation utilities.

 This class provides static utility methods for input/output operations.
 closeQuietly - these methods close a stream ignoring nulls and exceptions
 read - these methods read data from a stream
 write - these methods write data to a stream
 copy - these methods copy all the data from one stream to another
 contentEquals - these methods compare the content of two streams


Object Serialization :

Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent storage or streamed across a communication link. The byte stream can then be deserialised - converted into a replica of the original object.
import java.io.*; 
public class SerializationDemo { 
public static void main(String args[]) { 
// Object serialization 
try { 
MyClass object1 = new MyClass("Hello", -7, 2.7e10); 
System.out.println("object1: " + object1); 
FileOutputStream fos = new FileOutputStream("serial"); 
ObjectOutputStream oos = new ObjectOutputStream(fos); 
oos.writeObject(object1); 
oos.flush(); 
oos.close(); 
} 
catch(Exception e) { 
System.out.println("Exception during serialization: " + e); 
System.exit(0); 
} 
// Object deserialization 
try { 
MyClass object2; 
FileInputStream fis = new FileInputStream("serial"); 
ObjectInputStream ois = new ObjectInputStream(fis); 
object2 = (MyClass)ois.readObject(); 
ois.close(); 
System.out.println("object2: " + object2); 
} 
catch(Exception e) { 
System.out.println("Exception during deserialization: " + 
e); 
System.exit(0); 
} 
} 
} 
class MyClass implements Serializable { 
String s; 
int i; 
double d; 
public MyClass(String s, int i, double d) { 
this.s = s; 
this.i = i; 
this.d = d; 
} 
public String toString() { 
return "s=" + s + "; i=" + i + "; d=" + d; 
} 
}