Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
FileInputStream p = new FileInputStream(file1);
error on this line error java 18

What I have tried:

package readwrite;

import java.io.IOException;

//import java.util.Scanner;

public class maininput {

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//Scanner x = new Scanner(System.in);
//System.out.print("enter name");
//String a = x.nextLine();
//System.out.println(a);

readwrite r = new readwrite();
r.a();
}

}

"readwrite"

package readwrite;
import java.util.Scanner;
import java.io.*;

public class readwrite {

File file1 = new File("f:\\readwrite.xml");
public void a() throws IOException{

PrintWriter w = new PrintWriter(new FileWriter("f:\\readwrite.xml",true));
Scanner s = new Scanner(System.in);
String a = s.nextLine();
w.println(a);
w.close();
FileInputStream p = new FileInputStream(file1);

InputStreamReader i = new InputStreamReader (p);
BufferedReader b = new BufferedReader(i);
String read ="";
while(read!=null){
read = b.readLine();
if(read.equals(null)){
break;
}
else {
System.out.println(read);
}
}



}
}
Posted
Comments
Richard MacCutchan 17-Mar-16 6:02am    
This is the fourth question I have seen from you today, two of which are the same issue. The code above looks substantially like the other questions, but you have not explained what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900