Home Answers Viewqa Java-Beginners Java Create a file that contains your favorite movie quote

 
 


bob
Java Create a file that contains your favorite movie quote
1 Answer(s)      11 months ago
Posted in : Java Beginners

Create a file that contains your favorite movie quote. Use a text editor such as Notepad and save the file as Quote.txt. Copy the file contents and paste them into a word-processing program such as Word. Save the file as Quote.doc. Write an application that displays the sizes of the two files, as well as the ratio of the two file sizes. Save the file as FileStatistics2.java.

View Answers

June 19, 2012 at 11:56 AM


Here, we have created a text editor such as Notepad and save the file as Quote.txt and ask the user to enter the favorite movie quote. Then write it into the text file and Copy the file contents and save them into a word file 'Quote.doc'. After that, we have displayed the sizes of the two files.

import java.io.*;
import java.util.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hwpf.extractor.WordExtractor;

class FileStatistics2
{
    static void writeToFile(String content, String path){
        try{
        POIFSFileSystem fs = new POIFSFileSystem();
        DirectoryEntry directory = fs.getRoot();
        directory.createDocument("WordDocument", new ByteArrayInputStream(content.getBytes()));
        FileOutputStream out = new FileOutputStream(path);
        fs.writeFilesystem(out);
        out.close();
        }
        catch(Exception ex) {
        System.out.println(ex.getMessage());
       }
    }
    public static void main(String[] args) 
    {
        File f=new File("c:/Quote.txt");

        try{
        Scanner input=new Scanner(System.in);
        System.out.println("Enter fav movie quote: ");
        String str=input.nextLine();
        BufferedWriter bw=new BufferedWriter(new FileWriter(f,true));

            bw.write(str);
            bw.newLine();
            bw.close();

        BufferedReader br=new BufferedReader(new FileReader(f));
        String s="",st="";
        while((s=br.readLine())!=null){
            st+=s+" ";
        }
        File file=new File("c:/Quote.doc");
             writeToFile(str,file.getPath());
             System.out.println("Text File Size: "+f.length());
             System.out.println("Word File Size: "+file.length());

        }
        catch(Exception e){}
     }
    }









Related Pages:
Java Create a file that contains your favorite movie quote
Java Create a file that contains your favorite movie quote  Create a file that contains your favorite movie quote. Use a text editor such as Notepad... the user to enter the favorite movie quote. Then write it into the text file and Copy
movie class..(dr java) - Java Beginners
movie class..(dr java)  hi there.....am about to create a movie class.... but need to declare the name of movie , name of director of movie...)); list.add(new movie("Bhoot","Ram Gopal Verma",false)); File file = new File("C
Movie and Cinema class - Java Beginners
Movie and Cinema class  Hi, I'm new in java. Can someone help me...: Question: 1. Create a new Movie class which has two properties, title... the family members. Next create a new movie and use it to set the movie property
Movie clip in flex
Movie clip in flex  Hi... What is a MovieClip? IUIMovieClip? please... direct any movie clip to stop, play, or go to another point on the timeline, it cannot be used to dynamically create a timeline or add content at specific
youtube movie
youtube movie  how to get you tube movie in java please help me for code thanks in advance raman
How to create a new text file that contains the file names of the copied files in a new directory? - Java Beginners
How to create a new text file that contains the file names of the copied files in a new directory?  Okay so my question is: How to create a new text file that contains the file names of the copied files in a new directory
Adding slash "\" character before quote "'" in a query
before the quote. For example if the user enters "What's your name?" then we... in your java application to add the slashes. public String addSlashes... Adding slash "\" character before quote "'"
Show Time Maps
Show Time Maps       Quickly find and compare movie times at your favorite theaters through a map-based interface. While in beta, we are serving only Los Angeles and Austin markets
Create Your Own Package
Create Your Own Package       The package to which the source file belongs is specified with the keyword package at the top left of the source file, before the code
Create JAR file - Java Beginners
Create JAR file  Respected Sir, I got the answer from your side. But do let me know, isn't there any other way of making a JAR File. Simply like... each time in order to run your JAVA program on some other computer, it;s better
My Favorite Java Books
Java NotesMy Favorite Java Books My standard book questions When I think.... Favorite Java books from JavaLobby poll I've extracted many of the books from... for you, but probably not the right book to start your Java learning
I need your help - Java Beginners
the file name is ApplicationDelivery.java Your program must follow proper Java...I need your help  For this one I need to create delivery class... contains eight digits. The first four digits represent the year; the last four
create
create  how to create an excel file using java
How To Create a New File
store String, characters, numbers etc. In Java to create a File for storing... which will demonstrate you about how to create a new file in Java...How To Create a New File In this section we will discuss about how to create
how can create a jar file - Java Beginners
how can create a jar file  plz any one help me which file can i create the jar file plz give exact command  Hi The basic format... that you want to create a JAR file. * The f option indicates that you want
How to create XML file - XML
creating your file save it with .xml extension.  Hi,Java programming...()); }}Thanks  Hi,Java programming language has many API's to create xml file from...How to create XML file  Creating a XML file, need an example. Thanks
About search and replace contains of .doc or .docx file using java.
About search and replace contains of .doc or .docx file using java.  ... format but I am unable to do it. For example word document contains name [CutomerName] Address [Cs_add] This is my template file. I want
Create Tag Library Descriptor (TLD) File
, we learn how to create library descriptor file in your project. Developers can... Create Tag Library Descriptor (TLD) File  ... these steps to create the file:   1. Go to project option and right click
Java Question Anyone need some HELP !!
Java Question Anyone need some HELP !!  Create a file that contains your favorite movie quote. Use a text editor such as Notepad and save the file... the favorite movie quote. Then write it into the text file and Copy the file contents
Using Single Quote in Reciepient mail Id.
Using Single Quote in Reciepient mail Id.  Hi, Is it possible to send a mail to a Mail Account having singlequote (Ex: prasad'g@gmail.com) by using JAVA Mail API. Could you please give me the clarification.......   Hi
Java Objectives Question
as FileStatistics.java. Exercise 2: Create a file that contains your favorite movie quote. Use...Java Objectives Question  Exercise 1: Create a file by using any word... that contains the name of the user's favorite book and then displays it to the user
the specified dsn contains an architecture mismatch between the driver and application windows 7
Microsoft file system. After installing this patch your java program should be able... 2010 Redistributable and then try to run your program. This download contains...the specified dsn contains an architecture mismatch between the driver
Pyramid Multiplex Online movie ticket booking
to add movies for each theatre which contains movie name, star cast, director...Pyramid Multiplex Online movie ticket booking  Pyramid multiplex is setting up itsā?? online movie ticket booking to enhance the audience experience
Create zip file in Java
Create zip file in Java     .... You will also learn how to create a zip file from any file through the java... applications. This program shows you how to zip any file through your java
Creating your own package in java
and subpackage click on the following links Create Your Own Package Create...The package to which the source file belongs is specified with the keyword package at the top left of the source file, before the code that defines
Need to push the combo box to flash movie - Java Beginners
Need to push the combo box to flash movie   Hi, I need to push the combo box values to the flash movie. I am succusfull in pushing the textfield using some pushand getMovie methods in java scripts and HTML[here we enter
Online Radio Applications ? Listen To All Your Favorite Songs On The Go
Online Radio Applications – Listen To All Your Favorite Songs On The Go... and listen to your favorite songs wherever you are. The downside was still carrying... for a while but still want to stay in touch with your favorite stations back home
Create your own Notepad in Java
Create your own Notepad in Java           You must have worked with Notepad to write programs. Now its turn to create notepad by own with the help of java language
Create File in Java
CreateFile1.java C:\nisha>java CreateFile1 New file "myfile.txt" has... Create a File        Introduction Whenever the data is need to be stored, a file is used
Create and Save Excel File in JSP
Create and Save Excel File in JSP  .... Java program allows to you to create any number of excel sheets in an excel file.  To create an excel sheet we can use third party API which is Apache
How to create a jar file
???   The given code creates a jar file using java. import java.io.*; import...How to create a jar file  Hello!!!! I have a project which has...; protected void createJarArchive(File jarFile, File[] listFiles) { try
java program to create xml file with append data in well-formed
java program to create xml file with append data in well-formed   Sorry sir your given xml append data program is not well-formed. I'll make you more clear what I want. If this is my xml file Tom Cruise 45 Now when I append
Java file create new file
Java file create new file This section demonstrates you how to create a new... of these tools, you can can easily create a new empty file. Now for this task, we have... createNewFile(), you can create a file. Output: File is created
Download Search Engine Code its free and Search engine is developed in Servlets
and unzip the file into your favorite directory.  Create a database on your MySQL Server. Run all the queries from the source.txt file
CREATE AND WRITE FILE THREAD JAVA
CREATE AND WRITE FILE THREAD JAVA  Hi guys I was wondering how can I make this program in java with threads. I need to create a file and write in it (i know how to do that) but by listening in some port all the data that is being
Create XML file from flat file and data insert into database
Create XML file from flat file and data insert into database... have developed an application to create xml file from flat file and data...). Create a file "FlatFileXml.java"  used to create an XML and data
Create and Show Wordpad File on JButton Click - Java Beginners
Create and Show Wordpad File on JButton Click  Hello Sir I want to create wordpad or word document on JButton Click Event.which contains data which..."); JOptionPane.showMessageDialog(null,"Inserted into File
Create - XML File (Document)
Create - XML File (Document)     ... file with its version and encoding.  Here is Java File: CreatXMLFile.java... CreatXMLFile Enter number to add elements in your XML file: 3
Select your project and right click on the it
on "META-INF" folder and select New => File: New File dialog box is appear on the screen. Give a file name "persistence.xml" in File name text box and click on "Finish" button
Create Temp File
Create Temp File       In this section, you will learn how a temporary file... of program will help you in creating a Temporary File to your default directory. Here
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
Java Create Directory
The following example will show how to Create Directory in Java. Though... of the program. For this we cerate a file object in File class which will create a new... is already created" will be displayed. Example of Java Create Directory
create table in mysql of split file created in java
create table in mysql of split file created in java  i have created splite file in java. now i want to create table from splited data how to do
Writing your First WAP Application.
; Writing your First Application.Now it's time to mould your Internet Data... Getting Started To write a WML page you can use your
I want simple steps to create Jar File of Java Project - Java Beginners
I want simple steps to create Jar File of Java Project  Hello Sir How I can Create Jar File of Java Project,plz Help Me  Hi Friend... *.java 5. Create a manifest file: C:\examples> echo Main-Class
Java Property File
Java Property File This section contains the detail about property file, it's use and how can we read it via our Java code. What is property file...=Roseindia message = Welcome to \ Roseindia! If your key contains spaces
Create File in Java
of how to create a file in java: package FileHandling; import java.io.File...File is nothing but a simple storage of data in Java language. We call one... and text data to the file. The File.createNewFile() method is used to create
FILE
FILE  There is a file named Name.txt that contains information related to appliances.I want to read the contents of this file and I used the code...;Java Read content of File import java.io.*; public class Appliance { public

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.