0

I am starting out in programming and have little knowledge of Java. I use linux and after a while got sick of using gedit and javac to learn. So I now use eclipse. I am trying to get input from a text file and when I write the code I get and error that says "outputStream cannot be resolved" (it also happens with inputStream). All your help is appreciated!

Edited by scarface9477: n/a

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by scarface9477
0

1) Did you import their package? // import java.io.*;
2) Java is case sensitive: OutputStream, InputStream
3) Do the above and then post code if they don't work

0

1) Did you import their package? // import java.io.*;
2) Java is case sensitive: OutputStream, InputStream
3) Do the above and then post code if they don't work

I fixed the case sensitive problem, and had the import package part right, but I still get the same problem. Thanks again for your help.

import java.io.*;

public class anything {

	public static void main(String[] args) {
		
		try {
			OutputStream = new FileWriter("timeremaining.txt");
			
			int c;
			
			while ((c = InputStream.read()) != -1) {
				OutputStream.write(10 - c);
			}
			
			finally {
			if (OutputStream != null) {
                OutputStream.close();
            }
				
			}
			
		}
		
	}

}

Edited by scarface9477: n/a

0

This is how you instantiate an Object:

NameOfClass noc = new NameOfClass();

Not like this:

[B]OutputStream[/B] = new FileWriter("timeremaining.txt");

And call the methods like this:

noc.method1();
int a = noc.method2();

It seems to me that you don't know the very basic of instantiating objects so forget about the reading from file stuff and practice more on the basics

0

Ok, thank you very much for your help. I'll definitely go back and do the basics again.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.