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



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

Have Programming Question? Ask it here!
 
 
 


bob
Java Create a file that contains your favorite movie quote
1 Answer(s)      2 years and 2 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.


Advertisement
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 Tutorials/Questions & Answers:
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
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
Advertisements
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
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
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 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
youtube movie
youtube movie  how to get you tube movie in java please help me for code thanks in advance raman
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
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
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 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
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
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
Create new file in java
Create new file in java We are going to discuss how to create new file in java.... With File class we create files and directories. Java File represents actual... create main method than we use try and catch block. We have created File object
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 "'"
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 pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar  How to create pdf file having paragraphs and alignments done using java and itextjar 5.10 version.? hope i get quick response
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
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
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
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
Java to create table in jsp file that include other jsp file
Java to create table in jsp file that include other jsp file  String jspContent = "table" += "tr" += "td" += "jsp:include page='fileSource... this http://www.roseindia.net/tutorial/java/core/files/javacreatetableinHTML.html
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
Example of contains method of hashset in java.
Example of contains method of hashset in java. The contains() is a method of hashset. It is used for checking that the given number is available..., it returns true otherwise false. Code:  HashSetToArray .java
how to create a jar file for java classes? - Java Interview Questions
how to create a jar file for java classes?  I have 2 classes x1 and x2. packages names are com.bank.xyz; how to create a jar file for classes...://www.roseindia.net/tutorial/java/io/createJarFile.html Hope that it will be helpful
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
we can create our own header file in java?n how to create?
we can create our own header file in java?n how to create?  we can create our own header file in java?n how to create
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
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
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
how to create .exe file of java application?? - Java Beginners
how to create .exe file of java application??  hi i want to know how to create exe file of whole application so that i can use that application... createJarArchive(File jarFile, File[] listFiles) { try { byte b
Java MappedByteBuffer example, How to create a large size file in java.
Java MappedByteBuffer example, How to create a large file in java. In this tutorial, you will see how to create a large file with the help...;} } Output C:\>java CreateFile File
Java arraylist contains
contains() method is used to check whether the element is present or not. It returns boolean value i.e. true or false. Example of Java Arraylist Contains import java.util.ArrayList; import java.util.List; public
Java create table in html file
Java create table in html file In this section, you will learn how to create table in html file. In the previous section, you have seen different operations... as an argument. Now we have used the html table tag to create a table in html file
Java Swing Create XML file
Java Swing Create XML file In this tutorial, you will learn how to create XML file using swings. Here is a code that accepts the data from the user through... and fetch all the data from textfields and create an xml file with proper
how to create a set up file of java web application
how to create a set up file of java web application  I have already developed a java web application using struts 2.x, jsp, oracle as a back end data... if any one knows how to do the java web application as a set up file, please help
how to create a set up file of java web application
how to create a set up file of java web application  I have already developed a java web application using struts 2.x, jsp, oracle as a back end data... if any one knows how to do the java web application as a set up file, please help
how to create a set up file of java web application
how to create a set up file of java web application  I have already developed a java web application using struts 2.x, jsp,tomcat server, oracle... to my client, so in this case I would like to make my product as a setup file,where
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
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 file create temp file
Java file create temp file This section illustrates you how to generate a temporary file. Description of code: A temporary file stores information... we have used createTempFile() method to create an empty temporary file. We have
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
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
FTP Server : Upload file
This tutorial contains description of file uploading to the FTP server using java
FTP Server : Download file
This tutorial contains description of file downloading from the FTP server using java
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
how to create ipa file
how to create ipa file  Hi, How to .ipa file? Thanks   Hi, Please check the thread Resources have been modified iPhone. Thanks
Advertisements
 

 

 

DMCA.com