2

Here's the code. It basically reads from the original code file and prints onto the terminal.

import java.io.*;
public class Quine
{
    static void Quine() throws IOException
    {
        FileReader fr = new FileReader("C:/Quine.java");        
        BufferedReader br = new BufferedReader(fr);
        String s = "";
        while((s = br.readLine()) != null)
        {
           System.out.println(s);
        }
    }
}

Practically, it works just fine, producing the same exact code as output. But by definition, does it qualify as a quine? Considering I'm still passing a file to it as a parameter. Despite it being a programmer-specified and not a user-entered input, is it still considered an input?

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Ronit Ray
  • 51
  • 2
  • it would only print the code of the class Quine anyways (not the source actually needed to make it runnable)... Where is your main method? – Willi Mentzel Dec 01 '15 at 11:27
  • additionally it would not qualify as a quine because the whole conept here depends on the fact the the source is located at "C:\Quine.java". Run it from somewhere else and it is broken. – Willi Mentzel Jun 30 '16 at 12:49

2 Answers2

6

It is not considered a valid quine, you have to avoid any I/O operation.

Opening the source code to print it out it's the first cheat to avoid!

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
Giuseppe Ricupero
  • 6,134
  • 3
  • 23
  • 32
2

It would only print the code of the class Quine anyways (not the source actually needed to make it runnable - the main method). So, no it is not a Quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121