Home Answers Viewqa Java-Interview-Questions Java String operations

 
 


Neeraj
Java String operations
2 Answer(s)      a year and 7 months ago
Posted in : Java Interview Questions

hi,

please suggest me how to write the java code for reading a file and ignore the commented lines in /......../ this dispaly the contents of the file without commented lines.

View Answers

October 4, 2011 at 3:31 PM


import java.io.*;
class ReadFileIgnoringSomeLines
{
    public static void main(String[] args) throws Exception
    {
        FileReader fr=new FileReader("data.txt");
        BufferedReader br=new BufferedReader(fr);
        StringBuffer buffer=new StringBuffer();
        String str;
        while((str=br.readLine())!=null){
            if(str.contains("//")||str.contains("/*")||str.contains("*/") ){
                continue;
            }
            else{
             buffer.append(str);
             buffer.append("\n");
            }

        }
        System.out.println(buffer.toString());
    }
}

October 4, 2011 at 5:10 PM


hi, Thanka a lot for help. Another help I need, please help me solve this problem.

please suggest me how to extract table name and find the no of select statement and insert statement from a file and dispaly the result of SELECT and INSERT tablewise i.e.

abc_table SELECT 4

pgm_table INSERT 5

Please tell me how to do the coding for this.









Related Pages:
Java String operations
Java String operations  hi, please suggest me how to write the java...*; class ReadFileIgnoringSomeLines { public static void main(String[] args... StringBuffer(); String str; while((str=br.readLine())!=null
Operations with Calendar
Operations with Calendar  I have the following as my known parameter...*; import java.text.*; public class GetDateFromDay{ public String...()); } public static void main(String args[]){ GetDateFromDay dt
binary addition,subtraction and modulus operations - Java Beginners
passed as string without using java functions like parseInt,toString etc. i.e... passed as string into binary form, and then perform addition,subtraction and modulus operations on these two binary numbers and finally dipaly the result in decimal
Java JMenuItem to perform file operations
Java JMenuItem to perform file operations In this tutorial, you will learn how to use JMenuItem class to perform file operations. Java Swing introduced... example in java swing through which you can perform open and save operations
Hibernate Performing the usual DB operations
HIBERNATE-BASICS Hibernate Performing the usual DB operations... the usual DB operations. Hybernate2 can be downloaded from http... a java class, which will be automatically persisted to Relational Database
String Number Operations in JavaScript
String Number Operations in JavaScript  ... of JavaScript and create your first JavaScript program.  What is String Number Operation? The JavaScript  String is a loosely type language. This is not mean
java i/o operations
java i/o operations  how to write integer data to a file in java using random access file object or file writer or data outputstream i have already tried the write and writeInt methods....plz help
Basic CRUD operations
=new ArrayList<Student>(); String client=request.getParameter...")) { System.out.println("I am in clent"); String id=request.getParameter("id"); String name=request.getParameter("name"); String college
Basic CRUD operations
=new ArrayList<Student>(); String client=request.getParameter...")) { System.out.println("I am in clent"); String id=request.getParameter("id"); String name=request.getParameter("name"); String college
Basic CRUD operations
=new ArrayList<Student>(); String client=request.getParameter...")) { System.out.println("I am in clent"); String id=request.getParameter("id"); String name=request.getParameter("name"); String college
Write an event driven program to perform the arithmetic operations as shown in the interface
Write an event driven program to perform the arithmetic operations as shown... the java programming code for that question. my question is here: Q. Write an event driven program to perform the arithmetic operations as shown
Java Swing Undo Redo Operations
Java Swing Undo Redo Operations Swing provides Undo and Redo functionality through javax.swing.undo package. The undo mechanisms allow users to unexecute...); setVisible(true); pack(); } public static void main(String[] args
string manipulation
string manipulation  write a java program that asks the user to enter a string(where a consonant means insert, a punctuation means return element... by remove the maximum operations
string manipulation
string manipulation  write a java program that asks the user to enter a string(where a consonant means insert, a punctuation means return element... by remove the maximum operations
string
string   difference detween "public static void main (String[] args) " and "public static void main (String args[])" in java but it executes both ,in java which one is legal   The only difference is style, where
string
string  java prgm to find total occurence of a given string pattern in a sentence
string
string  java prgm to find total occurence of a given string pattern in a sentence
String
String  How to Convert sunnapu gopal to Sunnapu Gopal in java using String
string
string  a java program using string function to input any string... ArrangeStringAlphabetically { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter string
string
string  a java program using string function that computes your... links: http://www.roseindia.net/tutorial/java/core/printInitials.html http://www.roseindia.net/answers/viewqa/Java-Beginners/13383-print-initials.html
string
string  how do i extract words from strings in java???   Hi... ExtractWords { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.print("Enter String
string
string  a java program to input a string and display the string...*; import java.io.*; public class FirstLetter{ public static String capitalizeFirstLetter( String str ) { final StringTokenizer st = new StringTokenizer( str
string
and also displaying that contain word? Like I want to find "a" in the string "This is example of java Programme" and also display word that contain "a" character.   Here is a java example that accepts a sentence from the user
string
string  program for String reverse and replace in c,c++,java e.g.Input:10,20,hello output:hello;20;10   Hi Friend, Try the following java...(String[] args) { String array[]=new String[5]; Scanner input
string
string  how we conunt the no. of words in java without using in pre defined method in java
string
string  a java program to replace all matching substrings
string
string  a java program using string function and access modifiers to automate the insurance company which will have to manage the information about policy holders Data Members: 1)Policy No 2)Name of policy holder 3)Address 4
Summary - String
Java: Summary - String String Concatenation Following table shows how to perform the string concatination operations. "abc" + "def... together. If either operand is String, the other is converted to String
How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji 34,23,56 this is the student marks in text file.this data read and calculate
Reverse String using Stack
the string using these operations. Here is the code: import java.util....Reverse String using Stack You all are aware of Stack, a data structure, having two fundamental operations: push and pop. In stacks, items are removed
Java string
Java string  Strings are immutable.But String s="Hello"; String s1=s+"World"; S.O.P(s1); means printing "Hello World". How
Java String
Java String  You are given two strings S1 and S2,Delete from S2 all those characters which occur in s1 also and create a clean S2 with the relevant characters deleted..write a pgm for this..pls send as soon as possible Thank you
Regular Expression Search Program
string related operations. This is the way to manipulate different kind of operations like search, edit and manipulating string can be performed by the regular... string to search: w Occurrence of the word is: 5 C:\java\util>
Java BigInteger example
Java BigInteger example       BigInteger class provides us operations for modular arithmetic... operations. Here in this example of BigInteger we have created two big integer
Java String
Java String       In this section, you will learn about the java string. Java String is a set... to a string literal in the object stream. The Java String object contains a sequence
Java String - Java Beginners
Java String  How to seperate the string into characters.  there is a method called getChars() in String class,plz use that and separate into characters so plz verify the String api for related questions 
string - Java Beginners
string in java interview questions  What is string in java? Interview questions
string manipulation
string manipulation  Write a program in java and accept 10 strings form the user. store them in an array. then find the string with the maaximum length and print
String in Java - Java Beginners
]); } } } ---------------------------------------------------- I am sending simple code of String array. If you are beginner in java...String in Java  hiiiii i initialise a String array,str[] with a size... in advance   Hello Antony Insted Using String Array Use StringBuffer
string prgm
string prgm  write a java program which read a sentence and print occurence of each vowels in it seperatly
string wap
string wap  WAP to convert stack trace in to a String . Write that Stack Trace in Error Log File along with the class name and Method Name that has thrown the error.in java language
Java string buffer
Java string buffer  what is stringBuffer and StringBuilder
How to convert into to String in Java?
How to convert into to String in Java?  Hi, How to convert into to String in Java? Thanks
String immutable - Java Beginners
String immutable  Why is String immutable?  See here Why String is immutable in Java
String question
String question  which method is used in java to eliminate the duplicate elements in String?   import java.util.*; class RemoveDuplicates{ public static void main(String[] args){ String[] str = new String[] { "Where
capitalizing string in java
capitalizing string in java  How to capitalizing string in Java?   String s = "some string"; String capitol = Character.toString(s.charAt(0)).toUpperCase(); String newString = capitol + s.substring(1,x
Java String Occurrence in a String
Java String Occurrence in a String   ... of a String in another String. Here we have already taken a String. Description of the code: In the program code given below, we will find another String
converting string to double in java
converting string to double in java  Please post an example to converting string to double in java. Thanks!   Convert String to Double Tutorial

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.