Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


venkatesh goud
filewriter
0 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


Hi this is venkatesh goud. I have written program for writing given string into .txt file but it is not displaying output currectly please give me solution for bellow problem. the control is not transfering to new line when \n used. But when i am opening this text file in wordpad or ms-word it is displaying currectly. I am usins windows XP service pack-2 operating system...

import java.io.*;
class BRRead {
public static void main(String args[])
throws IOException
{

String s="fjdsjf;sdj;f  \n"+"sddddddddddddddddd    \n"+"sdgggggggggggggggggggg \n";
        FileWriter fw=new FileWriter("c:/hello.doc");
        for (int i=0;i<s.length() ;i++ )
        {
            fw.write(s.charAt(i));
  }
    fw.close();

     FileOutputStream fos=new FileOutputStream("c:/myfile1.txt");
     String ch="Now is the time for all good men\n"+ " to come to the aid of their country\t ddd \n"+ " and pay their due taxes.";
     byte[] b=ch.getBytes();
     fos.write(b);
     fos.close();

}
}

the output displaying in same line and instead of new line(\n) small square displaying please send me solution


Advertisement
View Answers

Related Tutorials/Questions & Answers:
filewriter
\n"+"sdgggggggggggggggggggg \n"; FileWriter fw=new FileWriter("c
How to write to file using FileWriter
using FileWriter thanks,   Hi, To writing in a file in Java program we uses a class in java.io package named FileWriter. The main object of the FileWriter class can be created using the following of its constructor i.e. FileWriter
Advertisements
Java Write To File FileWriter
Java Write To File FileWriter In this example you will learn how to write to file using FileWriter. Writing to a file there is a class in java.io package named FileWriter. Object of this class can be created using the following
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?  write a program in java to read a text file and write the output to an excel file using filereader and filewriter
Append a string to an existing file
to append a string to existing file. This will be done using FileWriter() constructor method of  FileWriter Class. The syntax is given of FileWriter constructor : public FileWriter(File file, boolean append) throws IOException
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter and BufferedWriter. Class FileWriter: The FileWriter class is used to write... OutputStreamWriter on a FileOutputStream. There are various constructors of FileWriter class
SCJP Module-10 Question-7
Given a sample code: import java.io.*; class Test3 { public static void main(String[] args) { try { File w = new File("test.txt"); FileWriter fw = new FileWriter(w); fw.write("test message"); fw.close
SCJP Module-10 Question-6
;user1.txt"); 6    FileWriter fw = new FileWriter(w); 7  
Java Write To File End Of Line
the FileWriter("String fileName", boolean append) this constructor creates a FileWriter object with the given file name with retaining the old text. You may wrap the FileWriter object to the higher level output stream
Java File Writing Example
the fileWriter object to the BufferedReader constructor. and write some data using bufferedWriter object and finally close it. FileWriter fileWriter = new FileWriter("sampleFile.txt", true); BufferedWriter bufferedWriter = new
How to Write to a File in Java
classes FileWriter and BufferedWriter. FileWriter FileWriter is a class, which...[]) { try{ // Create file FileWriter fstream = new FileWriter("out.txt... Java" into out.txt file. While creating the object of FileWriter class we
Java get default Charset
. In our example java program we have created an object of FileWriter and then we...; FileWriter filewrt = new FileWriter("out");  
Java Write To File From String
) to the FileWriter instance to write the character-stream. You can also passed the FileWriter object to the higher level output stream instance... and then pass this file object to the FileWriter instance to write characters
how to write append file in Java
to FileWriter constructor to write a stream of characters. The Constructor of the FileWriter class that I should be used like FileWriter fw = new FileWriter
Writing to File in Java
through using some defined classes such as FileWriter or BufferedWriter... class functions particular tasks. In Java, FileWriter and BufferedWriter... OutputStreamWrite class is used to handle raw byte file. Class FileWriter
How to Write to a File in Java without overwriting
we are using the FileWriter class of the java.io package. Our examples code... for this purpose. The object of FileWriter is created using the following code: FileWriter fstream = new FileWriter("log.txt",true); Here is the syntax
to read a file and seperate vowels and consonants to other files
InputStreamReader(in)); FileWriter ostream = new FileWriter("C:/Documents... BufferedWriter(ostream); FileWriter opstream = new FileWriter("C:/Documents
Java Write To File - Java Tutorial
For writing data to a file, the class FileWriter and BufferedWriter are used.  FileWriter :  FileWriter is a subclass...) to a file. You create a FileWriter by specifying the file to be written
How to write into CSV file in Java
the text into column. For this we have to use the filewriter constroctor, which passed the file name to write into a stream characters. Then we use the FileWriter
SCJP Module-10 Question-9
Re-arrange the code for writing into a text file. (1) place code here = new FileWriter("out.txt"); (2) place code here out = new (3) place code...) FileWriter fstream (Y) BufferedWriter (Z) BufferedWriter(fstream); Options: (A) 1-X
input output in java
input output in java  java program using filereader and filewriter   Hi Friend, Try the following code: import java.io.*; class... { FileReader in = new FileReader("C:/Hello.txt"); FileWriter out = new FileWriter
files
files  Question:How to create a new text file in another directory..(in which .class file is not there)... Discription:If we use the class FileWriter to write data to a new file then a new file
open a bufferedwriter file in append mode - Java Beginners
to opena bufferedwriter file in append mode..  Hi friend, FileWriter The FileWriter is a class used for writing character files. This constructor... ) { try { FileWriter fwo = new FileWriter( "output.txt", false
Files - Java Beginners
BufferedWriter(new FileWriter(file,true)); bw.newLine(); } else { bw = new BufferedWriter(new FileWriter(file)); } bw.write(str); I hope this will help...()){ FileWriter fstream = new FileWriter(file,true); BufferedWriter out
Java Write To File Append
WriteToFileAppend.java where I have used the FileWriter constructor to write a stream of characters. Argument 'true' of FileWriter constructor denotes... in an existing files. Constructor of the FileWriter class that I have used
how to write greater than symbol in a file using java
as a string like: FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out
java - Java Interview Questions
FileWriter fstream = new FileWriter("out.txt"); BufferedWriter
Java Write To File BufferedWriter
time to write. These Writer can be FileWriter, OutputStreamWriter etc. In the example given below I wrapped the FileWriter object in it. In the example... it into the FileWriter object to write the character-output stream. And to write efficiently I
Java Write To File - Java Tutorial
will use the class FileWriter and BufferedWriter to write to a file. Class FileWriter The FileWriter is a class used for writing character files. The constructors...; FileWriter fstream = new FileWriter("out.txt"
Java Write to File
package. Here in this example I have used the classes FileWriter and BufferedWriter. FileWriter : This class writes the streams of characters... time to write. These Writer can be FileWriter, OutputStreamWriter etc. Example
 

 

 

DMCA.com