Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Imitate a file system

 Kevin
Kevin 


Write a Java program to imitate a file system of an operating system. Design a class called BasicFile with options to carry out the following operations: 1. Select and open a file using a file dialog box; and display its contents in a scrollable pane. 2. Make a copy of the file, whether it is a text file or an image file. 3. Write to an output file with the option of either appending to the file, or over-writing the contents of the file. 4. Display the following attributes of the input file in a scrollable screen: i. The absolute path of the file ii. The size of the file in kilobytes. iii. The number of lines in the file, if the is a text file. 5. Search the input file line by line for a given string. The output must contain the line number, followed by the contents of the line that contains the search argument. For instance given the following the search string: Java, the program would search the file line by line generating a result such as the following: 50: on the island of Java 95: The people of JAVA loves jaVa. Use recursion to search the file. You may utilize the classes BasicFile and TestBasicFile as a source of reference. Attachments Tags Clarifications

Answers

Program

sudheer488
sudheer488 



Program Attachments
screen.docx (2125 K) Download
output.rar (80 K) Download










Preview
javax.swing.*; import java.awr.*; public class test{ private JFrame f; Private Jpanel p;

Preview
-post-compile-test-single: called after javac compilation of single JUunit test -pre-jar: called before JAR building -post-jar: called after JAR building -post-clean: called after cleaning build products (Targets beginning with '-' are not intended to be called on their own.) Example of inserting an

Preview
<j2seproject3:copylibs manifest="${tmp.manifest.file}"/> <echo level="info">To run this application from the command line without Ant, try:</echo> <property location="${dist.jar}" name="dist.jar.resolved"/> <echo level="info">java -jar "${dist.jar.resolved}"</echo> </target> <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.

Preview
<?xml version="1.0" encoding="UTF-8"?> <project-private xmlns="http://www.netbeans.org/ns/project-private/1">

Preview
<source-roots> <root id="src.dir"/> </source-roots> <test-roots>

Preview
array"+al); recursiveSearch(lnr.readLine(),key,lnr); return "Line " + al.toString(); } else { recursiveSearch(lnr.readLine(), key, lnr ); } } return currentLineText; } public String exten(){ String name = f.getName(); try { return

Preview
Array of choices choice[1]); // Initial choice if(s1.equalsIgnoreCase("appened")){ String pathout=f.getPath(); DataInputStream dis=new DataInputStream(System.in); FileOutputStream foutapp=new FileOutputStream(pathout,true); BufferedOutputStream bout=new BufferedOutputStream(foutapp,1024); System.out.println("enter text @ to end th text"); char ch; while((ch=(char)dis.read())!='@'){ foutapp.write(ch); } JOptionPane.showMessageDialog(null, "you entered @ finished

Preview
new byte[fstream.available()]; fstream.read(b); content = new String(b); jTextArea1.setText(content); br=new BufferedReader(new FileReader(f)); while((currentline=br.readLine())!=null){ System.out.println(currentline); s+=currentline; // tf.setText(s); } // ServiceProvider sr=new ServiceProvider(); if (!f.exists()) throw new FileNotFoundException(); } catch (Exception e)

Screenshots
Purchase Answer