File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes i/o about printwriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "i/o about printwriter" Watch "i/o about printwriter" New topic
Author

i/o about printwriter

gul khan
Greenhorn

Joined: Feb 14, 2001
Posts: 17
mport java.io.*;
class Characters {
public static void main(String [] args) throws IOException{
char vChar;
PrintWriter out= new PrintWriter(new BufferedWriter(new FileWriter("Characters.txt")));
for (int i=33;i<255;i++) {
vChar=(char) i;
System.out.println("<Number :"+i+" In Character is: "+vChar+">");
String vString= "<Number :"+i+" In Character is: "+vChar+">";
out.write(vString);
}
}
this file produces output to consele and also creates file "Character.txt" but file is empty
i m unable to figure out why?
any comment.

nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
You write vString= "" to file Characters.text, that is why file is empty. There is no doublt here,gul.
Try the following code, you can have i in file Characters.txt;
import java.io.*;
class Characters {
public static void main(String [] args) throws IOException{
char vChar;
PrintWriter out= new PrintWriter(new BufferedWriter(new FileWriter("Characters.txt")));
for (int i=33;i<255;i++) {
vChar=(char) i;
System.out.println("");
String vString = Integer.toString(i);
out.write(vString);
}
out.close();
}
}


Have you tried this Mock Exam Testing Engine yet?<br /><a href="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
gul khan
Greenhorn

Joined: Feb 14, 2001
Posts: 17
hello that line was mistake
i changed the code
<code>import java.io.*;
class Characters {
public static void main(String [] args) throws IOException{
char vChar;
PrintWriter out= new PrintWriter(new BufferedWriter(new FileWriter("Characters.txt")));
for (int i=33;i<255;i++) {
vChar=(char) i;
System.out.println("<Number :"+i+" In Character is: "+vChar+">");
String vString= "<Number :"+i+" In Character is: "+vChar+">";
out.write(vString);
}
}
this file produces output to consele and also creates file "Character.txt" but file is empty
i m unable to figure out why?
any comment.
see io it doent print anyway
i also used
String vString = Integer.toString(i);
file is created but nothing in it
</code>
any help

[This message has been edited by gul khan (edited March 03, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i/o about printwriter