|
how to write main class for run this class.
1. edit this class.
2. create main class for run
I need to write , read text file path C:\\file.txt
anyone help me please.
package
import java.io.*;
public class TextFileOperator {
public TextFileOperator(String path){
f = new File(path);
}
File f;
public void write(String text, boolean isAppend){
FileOutputStream out = new FileOutputStream(f,isAppend);
OutputStreamWriter wr = new OutputStreamWriter(out);
wr.write(text);
wr.close();
out.close();
}
public String read()
{
FileReader reader = new FileReader(f);
BufferedReader bf = new BufferedReader(reader);
StringBuilder bd = new StringBuilder();
String s;
while((s = bf.readLine()) != null){
bd.append(s);
bd.append("\n");
}
return bd.toString();
}
}
|
|
|
|
|
Take a look at the Java Tutorials[^].
You just need to add something of the form:
public static void main(String args[])
{
}
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I want to learn java programming... after that i'll create a website for java , c , c++ programming tutorials specially for beginners, just like me..
|
|
|
|
|
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
May you please encote correctly your code and post what errors you have ?
|
|
|
|