import java.io.*;
class Abc
{
public static void main(String arg[])
{
try{
File f= new File("c:/xyz.txt");
FileOutputStream fout=new FileOutputStream(f);
byte data[]={65,66,67,68};
fout.write(data);
fout.close();}
catch(Exception e)
{
System.out.println(e);
}
}
}

You're missing an import statement for FileOutputStream, other than that, I can't spot any errors with this code. I think you'll have to explain a bit more about when you get this error. In what context are you using it?

Go to where the ".class" file is and type the command as java -cp . Abc

A mistake by di2daer.

You're missing an import statement for FileOutputStream.

When we use java.io.*; It means any class/interface of java.io package can be used in our program file without qualify it with java.io package name.

whops, thank you for pointing that out :)

whops, thank you for pointing that out :)

You are welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.