Skip to main content

Posts

FILE HANDLING IN JAVA

About File Handling File handling in Java is frankly a bit of a pig’s ear, but it’s not too complicated once you understand a few basic ideas. The key things to remember are as follows. You can read files using these classes: FileReader for text files in your system’s default encoding (for example, files containing Western European characters on a Western European computer). FileInputStream for binary files and text files that contain ‘weird’ characters. FileReader (for text files) should usually be wrapped in a BufferedFileReader . This saves up data so you can deal with it a line at a time or whatever instead of character by character (which usually isn’t much use). If you want to write files, basically all the same stuff applies, except you’ll deal with classes named FileWriter with BufferedFileWriter for text files, or FileOutputStream for binary files. Reading Ordinary Text Files in Java If you want to read an ordinary text file in yo...

SELECT | INSERT | UPDATE | DELETE CODE IN VB.NET WITH AUTO INCREMENT CONCEPT

Database.vb Imports System.Data.SqlClient Public Class Database     Dim con As New SqlConnection( "Data Source=G20;Initial Catalog=Me;Integrated Security=True" )     Public Sub cnopen()         If con.State = ConnectionState.Open Then             con.Close()         End If         con.Open()     End Sub     Public Sub cnclose()         If con.State <> ConnectionState.Closed Then             con.Close()         End If     End Sub     Public Function Displaygrid( ByVal query As String ) As DataTable         Dim dt As N...

COMBO BOX BIND WITH SQL IN ASP.NET

private void bindcombo()     {         string sql = "select * from qualification_m" ;         DataSet ds = new DataSet ();         SqlDataAdapter da = new SqlDataAdapter ();         using ( SqlConnection myConnection = new SqlConnection (connectionString))         {             myConnection.Open();             SqlCommand myCommand = new SqlCommand (sql, myConnection);             myCommand.ExecuteNonQuery();             da.SelectCommand = myCommand;             da.Fill(ds);    ...

DIALOG BOX SHOW CODE IN SWING JAVA

import javax.swing.*; import java.awt.event.*; public class Dialog {   JFrame frame;   JPanel p;   public Dialog(){   frame = new JFrame("Show Message Dialog");   p=new JPanel();   JButton button = new JButton("Click Me");   button.addActionListener(new MyAction());     p.add(button);   frame.add(p);   frame.setSize(400, 400);   frame.setVisible(true);   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   }   public class MyAction implements ActionListener{   public void actionPerformed(ActionEvent e){   JOptionPane.showMessageDialog(frame,"My DialogBox");   }   }  public static void main(String[] args)  {     Dialog db = new Dialog();   } }

COMBO BOX EVENT HANDLING CODE IN SWING JAVA

package Swing; /**  *  * @author Administrator  */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ComboBox1 implements ActionListener { JFrame fr; JPanel p; JTextField t1; JComboBox c1;     ComboBox1()     {     fr=new JFrame("My ComboBox");         p=new JPanel();     t1=new JTextField();     p.setLayout(null);     c1=new JComboBox();     c1.addItem("INDIA");     c1.addItem("JAPAN");     c1.addItem("ENGLAND");     c1.addItem("AUSTRALIA");     c1.addItem("NEW ZEELAND");     c1.addActionListener(this);     t1.setBounds(120,60, 100,25);     c1.setBounds(20,60,100,25);     p.add(t1);     p.add(c1);     fr.add(p);     fr.addWindowListener(new wclose());     fr.setSize(500,500);     fr...