Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

io

Ads

 
 

Share on Google+Share on Google+

hrishikesh
io
1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners

write a program in java to accept a filename from user and print its content on the monitor

Ads
View Answers

December 23, 2010 at 1:16 PM


Hello Friend,

Try the following code:

import java.io.*;
import java.util.*;
class DisplayContentOfFile
{
    public static void main(String[] args) throws Exception
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter file: ");
        String str=input.nextLine();
        File file=new File(str);
        FileReader fr=new FileReader(file);
        BufferedReader br=new BufferedReader(fr);
        String line="";
        while((line=br.readLine())!=null){
            System.out.println(line);
        }
    }
}

Thanks


Ads









Related Tutorials/Questions & Answers:
Artifacts of io
List of Artifacts of io maven depenency
Version of commons-io>commons-io dependency
List of Version of commons-io>commons-io dependency
Advertisements
Version of excalibur-io>excalibur-io dependency
List of Version of excalibur-io>excalibur-io dependency
java io - Java Beginners
Java IO Streams  What is the Java IO Stream
IO concept
IO concept  Write a java program that moves the contents of the one file to another and deletes the old file.   Hi Friend, Try the following code: import java.io.*; class MoveFile{ public static void main(String
io
io
IO in java
IO in java  Your search mechanism will take as input a multi-word query and will return a list of documents where the given words appear. 1. Your score for this portion of the assignment will be based on the intelligence of your
io packages - Java Beginners
io packages  How can I add two integers in java using io pacages
java IO programing
java IO programing  how Java source file is used as input the program will echo lines
Artifacts of commons-io
List of Artifacts of commons-io maven depenency
Artifacts of excalibur-io
List of Artifacts of excalibur-io maven depenency
java binary file io example
java binary file io example  java binary file io example
Maven Dependency commons-io >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.0 in your project
Maven Dependency commons-io >> 1.3
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.3 in your project
Maven Dependency commons-io >> 0.1
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version0.1 in your project
Maven Dependency commons-io >> 1.1
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.1 in your project
Maven Dependency commons-io >> 1.3.1
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.3.1 in your project
Maven Dependency commons-io >> 1.2
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.2 in your project
Maven Dependency commons-io >> 20030203.000550
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version20030203.000550 in your project
Maven Dependency excalibur-io >> 1.1
You should include the dependency code given in this page to add Maven Dependency of excalibur-io >> excalibur-io version1.1 in your project
Version of drools>drools-io dependency
List of Version of drools>drools-io dependency
Version of excalibur>excalibur-io dependency
List of Version of excalibur>excalibur-io dependency
Version of com.cedarsoftware>groovy-io dependency
List of Version of com.cedarsoftware>groovy-io dependency
Version of com.cedarsoftware>json-io dependency
List of Version of com.cedarsoftware>json-io dependency
Version of com.indix>rocksdb-io dependency
List of Version of com.indix>rocksdb-io dependency
Version of com.jenjinstudios>jenjin-io dependency
List of Version of com.jenjinstudios>jenjin-io dependency
Version of com.sandinh>spray-io dependency
List of Version of com.sandinh>spray-io dependency
IO File - Java Beginners
IO File  Write a java program which will read an input file & will produce an output file which will extract errors & warnings. It shall exclude the standard errors & warnings. The standard errors & warnings you can find out
Import java IO - Java Beginners
Import java IO  for example i know java IO is for input and output. I am using Netbeans5.5.1. How can i see all the classes related to java IO for example; stream reader, buffer reader