Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

how to difficulty in removing error

Ads

 
 

Share on Google+Share on Google+

Meera
how to difficulty in removing error
2 Answer(s)      7 years ago
Posted in : Java Beginners
Ads
View Answers

December 14, 2009 at 4:30 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;
import java.util.regex.*;
class skeleton{
public static void main(String[]args)throws Exception{
Scanner input=new Scanner(System.in);
boolean quit = false;
int p=0;
System.out.println("1-create");
System.out.println("2-reading");
System.out.println("3-backup");
System.out.println("4-modifydata");
System.out.println("5-delete");
System.out.println("6-instruction");
System.out.println("7-exit");

do{
System.out.println("");
System.out.println("choose option from 1to7");
System.out.println("");
p=input.nextInt();
switch(p){
case 1:
System.out.println("Enter student's name: ");
String name=input.next();
System.out.println("Enter student's class: ");
int cl=input.nextInt();
System.out.println("Enter the student's division");
String div=input.next();
System.out.println("Enter the students roll No");
int roll=input.nextInt();
System.out.println("Enter the students marks in English Literature");
int lit=input.nextInt();
System.out.println("Enter the students marks in English Language");
int lang=input.nextInt();
System.out.println("Enter the students marks in Hindi");
int hin=input.nextInt();
System.out.println("Enter the students marks in History");
int hist=input.nextInt();
System.out.println("Enter the students marks in Geogrophy");
int geog=input.nextInt();
System.out.println("Enter the students marks in Mathematics");
int maths=input.nextInt();
System.out.println("Enter the students marks in Physics");
int phy=input.nextInt();
System.out.println("Enter the students marks in Chemistry");
int chem=input.nextInt();
System.out.println("Enter the students marks in Biology");
int bio=input.nextInt();
System.out.println("Enter the students marks in Enviromental Education");
int eve=input.nextInt();
System.out.println("Enter the students marks in Computer Application");
int ctsa=input.nextInt();
int total=lit+lang+hin+hist+geog+maths+phy+chem+bio+eve+ctsa;
File file = new File("C:\\report.dat");
FileWriter fw = new FileWriter(file,true);
BufferedWriter out = new BufferedWriter(fw);
out.write(name+" "+Integer.toString(cl)+" "+div+" "+Integer.toString(roll)+" "+Integer.toString(lit)+" "+Integer.toString(lang)+" "+Integer.toString(hin)+" "+Integer.toString(geog)+" "+Integer.toString(maths)+" "+Integer.toString(phy)+" "+Integer.toString(chem)+" "+Integer.toString(bio)+" "+Integer.toString(eve)+" "+Integer.toString(ctsa)+"Totals is:"+Integer.toString(total));
out.newLine();
out.close();
break;


December 14, 2009 at 4:31 PM


continue..

case 2:
FileInputStream fstream = new FileInputStream("C:\\report.dat");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println (strLine);
}
in.close();
break;
case 3:
BufferedReader reader = new BufferedReader(new FileReader("c:\\report.dat"));
Pattern pat = Pattern.compile(",(\".+?\")");
String line=null;
while ((line=reader.readLine())!=null){
Matcher matcher = pat.matcher(line);
StringBuffer sb = new StringBuffer();
while (matcher.find()){
matcher.appendReplacement(sb,","+matcher.group(1).replaceAll(",","&comm"));
}
matcher.appendTail(sb);
String[] fields = sb.toString().split(",");
for (int i=0;i<fields.length;i++){
String s = fields[i]!=null ? fields[i].replaceAll("&comm",",") : "";
FileWriter writer = new FileWriter("backup.dat",true);
BufferedWriter output = new BufferedWriter(writer);
output.write(s+",");
output.newLine();
output.close();
}
}
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
quit=true;
}
}
while (!quit);
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
how to difficulty in removing error - Java Beginners
how to difficulty in removing error  import java.io.*; class skeleton { public static void main()throws IOExeception { DataInputStream data=new DataInputSTream(System.in); int p=0; //loop variables to read cell value
Difficulty in plugging log4J with Hibernate.
Difficulty in plugging log4J with Hibernate.  I am using Hibernate 3.6. Followed your all instruction of plugging log4j with my hibernate code... log4j.properties in the class path. log4j.jar in the class path Still when I run
Advertisements
Removing the Title Bar of a JFrame
Removing the Title Bar of a JFrame  How to remove the Title Bar of a JFrame in Swing Application?   Please check the tutorial Removing the Title Bar of a Frame for the source code and example description. Thanks
Programming Difficulty - Java Beginners
are the student's scores on three exams. How to write a program that will read... exception if any System.err.println("Error: " + e.getMessage
how to resolve this JDBC Error?
how to resolve this JDBC Error?  i am trying to Exceute this code: import java.sql.DatabaseMetaData; import java.sql.Connection; import... but when i am executing this code i am getting this Error: Exception in thread
please how fix this error?
How to Fix Error   for this following code : $var1 = $_POST["name"]; $var2 = $_POST["id"]; $st = 'INSERT INTO USERNAME(id,name) VALUES(:var1,:var2)'; $query = ociparse($con,$st); OCIBindByName($st ,':va1',$var1
how to ignore http 500 error?
how to ignore http 500 error?  In XML data parsing while connecting to many server through URL if one does not connect gives the error. Is there any process to ignore that URL connection and get data from other connection which
Removing character from a string in sql.
Removing character from a string in sql.  How to remove or replace character from a string
How to trap Trigger Error - SQL
How to trap Trigger Error  Hi Guys, Can you please help with my problem?.. Is there a way in where I can trap all SQL error and place it under... error_log ( timestamp DATETIME, username NVARCHAR(30
How to Solve the Syntax Error in java??
How to Solve the Syntax Error in java??  Syntax error in java? i have tried this program its showing error like this in Eclipse "Syntax error... of the program "objectname.i" What is the reason for this error??How to access the variable
Removing existing cookie in jsp
Removing existing cookie in jsp  How remove existing cookie in jsp ?   If you want to remove an existing cookie, you can use the method setMaxAge() of that cookie object to set its timeout to zero.Example <[email protected]
Regular Expression for removing XML Tags
Regular Expression for removing XML Tags  Hi, Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified Text String like, String txt="<Hello>How are you"; I want output of this txt
Removing characters from a string
Removing characters from a string  Removing characters from a string   Example: public class CharReplace{ public static void main(String []args){ String str="Hello 123.you are At 3456"; String
How to fix HAX Kernel Module Is Not Installed error?
How to fix HAX Kernel Module Is Not Installed error?  Hi, How to fix HAX Kernel Module Is Not Installed error? Android studio gives following error: emulator: ERROR: x86 emulation currently requires hardware acceleration
Removing character from a string in sql.
Removing character from a string in sql.  Removing special characters from a string in sql
Removing HTML from a Java String
Removing HTML from a Java String  Removing HTML from a Java String
how to solve 'Stop Running This Script' Error ?
how to solve 'Stop Running This Script' Error ?  Hi.. When opened the page on IE browser(version : 8.0),it gives an java script error (i.e.Stop Running This Script). I have used jsp/servlet for this. Please help to resolved
how to solve this kind of error in Eclipse IDE?
how to solve this kind of error in Eclipse IDE?   i'm creating... are installed. but i'm getting exactly this error, any one out of this problem of error. thanks in advance. ![this is image of error, and i will try to start
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText... help me in removing errors in the above line
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText... help me in removing errors in the above line
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText... help me in removing errors in the above line
Difficulty using javascript in server side - Java Interview Questions
Difficulty using javascript in server side   why interaction with server using javascript is difficult
error occured in following page ... how to resolve it?
error occured in following page ... how to resolve it?  // to convert... error ....wht i shud do???????? i m java beginner so plz explain in smooth way.... error is:::: Exception in thread "main" java.lang.IllegalArgumentException
How to create and use custom error page in jsp
How to create and use custom error page in jsp       This is detailed java code how to create and use custom error page in jsp and display an error message. Before run
How to Send particular error to another page in Servlet from web.xml
How to Send particular error to another page in Servlet from web.xml  How to Send particular error to another page in Servlet from web.xml   Hi you can forward particular error from web.xml file as <error-page>
How do I throw a 404 error from within a java servlet?
How do I throw a 404 error from within a java servlet?  How you can write code in Servlet for throwing the httpd error 404? How to add the configuration for handling the not found error in the web.xml file? Thanks   
Wrapping, replacing, and removing content
Wrapping, replacing, and removing content       Wrapping, replacing, and removing content The JQuery provide efficient ways for wrapping, replacing, and removing
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this  java.lang.NumberFormatException: For input string: "7600113411"    java.lang.NumberFormatException: For input string
How to Checking Syntax Error in PHP from Command Line
How to Checking Syntax Error in PHP from Command Line  Checking Syntax Error in PHP from Command Line   PHP allows you to check your script.... It will check the syntax error in your script and show the ??Unexpected token
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version. This type error also comes when java file
error
(DriverManager.java:171) at excelDB.ExcelDB.main(Excel_DB.java:210) how to solve dis error