This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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).]
 
 
subject: i/o about printwriter
 
Similar Threads
Converting Zoned Decimal to Something Useable
print stream empty file
force users to use english character set
Storing HTML from WebPage
Help me fix this code, please.