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



Home Answers Viewqa Java-Beginners This is what i need

Have Programming Question? Ask it here!
 
 
 


alhisnawy
This is what i need
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


Implement a standalone procedure to read in a file containing words and white space and produce a compressed version of the file in an output file. The compressed version should contain all of the words in the input file and none of the white space, except that it should preserve lines.


for this question i need just :
one function can read string like (I like to play football)from a file (e.g,file.txt)then remove the spaces and the white spaces then just write this string in another file (e.g,file2.txt)as (Iliketoplayfootball)
without any compressing the file.

thank you

Advertisement
View Answers

February 20, 2010 at 5:13 PM


Hi Friend,

Try the following code:

import java.util.*;
import java.io.*;
import java.text.*;
import java.util.regex.*;

public class ReadFile{
public static void main(String args[]) throws Exception{
BufferedReader reader = new BufferedReader(new FileReader("c://data.txt";));
String line=null;

while ((line=reader.readLine())!=null){
String data = line.replaceAll(" ","");
FileWriter fstream = new FileWriter("out.txt",true);
BufferedWriter output = new BufferedWriter(fstream);
output.write(data);
output.newLine();
output.close();
}
}
}

Thanks


Related Tutorials/Questions & Answers:
This is what i need - Java Beginners
This is what i need  Implement a standalone procedure to read in a file containing words and white space and produce a compressed version of the file.... for this question i need just : one function can read string like (I like
what is java and why do i need it?
what is java and why do i need it?  Hi, Please tell me what is Java and why do i need it? Is it free to download? Also explain me how to write and test my first Java Application? What is the configuration or system requirement
Advertisements
This is what i need in this Question - Java Beginners
This is what i need in this Question  You are to choose between two... array. so i need your help to know is it correct or wrong Thank you... explaination with out coding In my understanding I choose the non-empty array
Java web development, what skills do I need?
Java web development, what skills do I need?  Java web development, what skills do I need
Java web development, what skills do I need?
Java web development, what skills do I need?  Java web development, what skills do I need
What do I need to do to use a MSSQL-Server with Web-Harvester?
What do I need to do to use a MSSQL-Server with Web-Harvester?  What do I need to do to use a MSSQL-Server with Web-Harvester
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
what is the need of... - Java Beginners
what is the need of...   what is the need of " return type like void ?   Hi Friend, In java, method always require a return type.The main method is the client code therefore jvm does not expected any return
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
hello there i need help
hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you... me with the codes and please explain to me how it works. i only need to use
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer n is written n! (pronounced ‚?? n factorial‚??) and is defined as follows: n!=n...=input.nextInt(); long num=m; for(int i=m;i>1;i
I need Spring 2.5 example.
I need Spring 2.5 example.  Hello, I am looking forward to learn Spring framework and hence I need Spring 2.5 and Spring 3.0 example.. Thanks
i need help to solve this problem
i need help to solve this problem  Write a stack class... and prints them in reverse order. and Show step by step what queue will look like.... H and I join the queue h. G leaves the queue i. H and I leave the queue
I need to develop a gui like this
I need to develop a gui like this  Hai Friends, I need to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text... please help me   sorry goes through this link I need to develop like
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
i need help - Development process
i need help  hello, i need help regarding this program. public...()); } } } it is printing the result of ping in to a file,but if i want... the result in to the files,if i want to do this i must make my program running
i need help - Development process
i need help  hello, i need help regarding this program. this program gives ping to the system. import java.net.*; import java.io.*; import... IPAddress on command line, but i want to take it dynamically and it must store
i need help plz .... Quickly
i need help plz .... Quickly   how can i count how many numbers enterd by the user so the output would be like this Total number of Scores = .... this is my code :- import java.util.Scanner; public class SCORES { public
regular expression expalanation i need
regular expression expalanation i need  hi......... here is my code could explain it <html> <script language = "Javascript"> function checkEmail() { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test
I need your help - Java Beginners
I need your help  What is the purpose of garbage collection in Java, and when is it used?  Hi check out this url : http://www.artima.com/insidejvm/ed2/gc.html http://java.sun.com/javase/technologies/hotspot
Dear Sir I need to join u
Dear Sir I need to join u  Dear Sir i am santosh Rai from Saudi Arabia please make me understood how to join u and i have one question i want to working with you what is ur process for working with u please send me
I need Oracle connector jar file. where will i download?
I need Oracle connector jar file. where will i download?  I need Oracle connector jar file. where will i download
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum+1,like automatically when i click the button...as well i have several kinds
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
I need add my java program with a picture.
I need add my java program with a picture.  Good evng Frnds Friends i created 1 jar file in my desktop. I need add this program with 1 picture... of opening Picture. I think most of the softwares are like that . They are first
i need a quick response about array and string...
i need a quick response about array and string...  how can i make a dictionary type using array code in java where i will type the word then the meaning will appear..please help me..urgent
pls i need help with my assignment
pls i need help with my assignment  how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints * and also using import java.util.Scanner
I need hibernate session factory example.
I need hibernate session factory example.  Hi, I want a simple hibernate session factory example..   hello, Here is a simple Hibernate SessionFactory Example Also go through the Hibernate 4 Thanks
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
I need help in doing this. - Java Beginners
I need help in doing this.  Student DataBase i will need creating... and their methods as needed. What program should do (Tasks): i) Read data in from..., and the student's GPA.using arrays and objects, need to structure the information
How to find the exact PHP template I need?
How to find the exact PHP template I need?  Hi! I'm a PHP Pro?I think I am one?, but this is the first time for me to try a PHP template, so I have..., Agavi, CakePHP, CodeIgniter) Which PHP template is the right one I am seeking
i need some help in understanding the following codes.thanks..
i need some help in understanding the following codes.thanks..  this code is to perform LocalColorHistogram.But i can't understand it public... * height; int i = 0; int j = 0; int k = 0; double
i need your help - Java Interview Questions
i need your help  Write a java program that: i. Allows user to enter 2 numbers from the keyboard ii. Uses a method to compare the two numbers to determine which is larger iii. Print to the screen stating which number is larger
i need to answer this Question but i can't do it probably
i need to answer this Question but i can't do it probably   use the web to locate the lyrics to the traditional song"The Twelve Days of Christmas" the song contains a list of gifts received for the holiday.the list is cumulative
need help pleaseee....i weak in java
need help pleaseee....i weak in java  QUESTION 1 You are required to write an application called Customer Billing System. This system...) Separate them as either R/r for Residential or I/i for Industrial. You can use
I need your help - Java Beginners
I need your help  For this one I need to create delivery class for a delivery service .however, this class should contain (delivery number which contains eight digits. The first four digits represent the year; the last four
for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0)
for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0)  for what value of i the loop executes for infinite times if i prove a condition like ( i !=i+0
If I open .class file with notepad what is displayed?
If I open .class file with notepad what is displayed?   What is displayed when we open java .class files with notepad
what should i do next?? - Java Beginners
what should i do next??  I know java basics.actully i passed the SCJP exam.Then now i have no idea about what should i do next.I like to come to the web development.I want to know which one i should study first.JSP or servlet
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void...++){ for( i=0;i<11-1;i++){ if((byte)c==(byte)first.charAt(i)) { count1
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void...++){ for( i=0;i<11-1;i++){ if((byte)c==(byte)first.charAt(i)) { count1
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |  import java.io.*; public class Sort{ public static void...++){ for( i=0;i<11-1;i++){ if((byte)c==(byte)first.charAt(i)) { count1
I want to build sessionfactory in hibernate 4. Need help.
I want to build sessionfactory in hibernate 4. Need help.  Hello, I want to build sessionfactory in hibernate 4. Need help
i need attendce management system source code in java
i need attendce management system source code in java  i need attendance management system source code in java
I need to display parts of my own website on another website in an iframe
I need to display parts of my own website on another website in an iframe  I need to display parts of my own website on another website in an iframe. please refer me how do i do
Not sure what I am missing ? Any ideas?
Not sure what I am missing ? Any ideas?  import java.util.*; public...) { if(str.length()==0) return false; for(int i=0;i<str.length();i++) if (c==str.charAt(i)); return true
i need latest oracle certified java dumps.. Pleas help me?
i need latest oracle certified java dumps.. Pleas help me?  i need latest oracle certified java dumps.. Pleas help me
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
Advertisements
 

 

 

DMCA.com