how to difficulty in removing error

how to difficulty in removing error

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









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
Removing character from a string in sql.
Removing character from a string in sql.  How to remove or replace character from a string
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 <%@page
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
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
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
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
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 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 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
Difficulty using javascript in server side - Java Interview Questions
Difficulty using javascript in server side   why interaction with server using javascript is difficult
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
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.ADS_TO_REPLACE_1 This type error also comes
error
(DriverManager.java:171) at excelDB.ExcelDB.main(Excel_DB.java:210) how to solve dis error
error
error  while iam compiling iam getting expected error
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
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error
"+it); } } this is my program i am getting an error saying cannot find symbol class stringADS
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
error
error  how do i set jdk home path in jcreator le
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
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
How to solve ModuleNotFoundError: No module named 'paramiko' error
'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error...How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error
How to solve ModuleNotFoundError: No module named 'paramiko' error
'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error...How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error
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
Removing a Row from a JTable
Removing a Row from a JTable     ... the JTable. For removing the data of row from JTable, you will remove it from... a table with some data by using the DefaultTableModel that helps us for removing
Removing duplicate white spaces from a String
Removing duplicate white spaces from a String       In this section, you will learn how... of removing all the duplicate white spaces from the given string. Program Result
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   
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 â
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
one error but i dont know how to fix it o_O!!!
one error but i dont know how to fix it o_O!!!  where is the mistake here ?? import java.utill.Scanner; public class Time { public static void..."); } } the compilar told me that there is only one error... thx

Ads