1

I'm trying to print the text within the quotes in a file. May I have anyone to help me.

E.g : "Jayaramachandiran"

This line is in a text file,and I wanna read it and print it.

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61
Jey
  • 383
  • 2
  • 4
  • 6
  • 1
    Also, what isn't working? What is the expected result vs the actual result? – OverZealous Aug 22 '11 at 04:35
  • do you want the code i developed so far? – Jey Aug 22 '11 at 04:36
  • Reading the text file line by line.then doing the operations in the text file like addition,.. – Jey Aug 22 '11 at 04:37
  • ya i could able to read a text file that's working properly. – Jey Aug 22 '11 at 04:46
  • But the actual problem is to read the text which is within the codes in that perticular file.e.g if i give PRINT "This is my first demo" in the text file. it should print the text which is in the qoutes alone. like an interpreter. – Jey Aug 22 '11 at 04:48

3 Answers3

1

Why don't you check out this link:

How do I create a Java string from the contents of a file?

It seems someone has answered your question already. :) The first answer to that question is your best bet.

P.S After reading the file into a string, just go ahead and output the string and voila!

Community
  • 1
  • 1
corecase
  • 1,278
  • 5
  • 18
  • 29
1

You may use a BufferedReader to read.

See this example:

import java.io.*;

class YourClass {

    public static void main (String[] args) throws IOException {
        BufferedReader fr = new BufferedReader(new FileReader("yourfile.txt"));
        String text = fr.readLine();
        fr.close();

        System.out.println(text);
    }
}
Diego Queiroz
  • 3,198
  • 1
  • 24
  • 36
0

You want to print a string from file, but removing characters, like the quotes, from it. I think it's better first to read the string from file, then remove the quotes.

Check this page.

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61