Frequently Asked Java Program 29: How To Read Data From Text File

Frequently Asked Java Program 29: How To Read Data From Text File

SDET- QA

4 года назад

78,525 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@swapnilshinde8577
@swapnilshinde8577 - 29.04.2022 11:25

sir i think we have to write fr.close(); on the place of br.close(); because fr is handling file. please revert.

Ответить
@rafy-ivanmorales3077
@rafy-ivanmorales3077 - 30.12.2021 04:00

I’m a new student and need help to do this project:
I have a port scanner script it works properly, it works in Pycharm using python3.9.
I have to make a file and I did make call (Example.txt)
On this file, I have to do this:
3. If the Ports is open, it should create a file and add an entry for port number
4. In case of any exception for instance “host is not available”, “host name could not be resolved” or
due to any other error, you need to write that exception into the same file.
I’m not asking for you to do the project for me, I'm only asking ware I need to work or used in my script to accomplish this because it is my first time doing this and working with python too, and I have been struggling with this part one very bad. I can even send you the code, so you can look and only tell me what I’m doing bad, is not working.

Ответить
@DeepakyadavSEO
@DeepakyadavSEO - 05.07.2021 04:46

Getting Null in output.


import java.io.BufferedReader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class ReadDataFromTextFile {

public static void main(String[] args) throws IOException {
FileReader file=new FileReader("C:\\Users\\prakhar\\Desktop\\R.txt");
BufferedReader bf = new BufferedReader(file);
String str;
while(( str=bf.readLine())!=null);{
System.out.println(str);
}
bf.close();
}

}

Ответить
@salehashamim7803
@salehashamim7803 - 08.03.2021 09:15

Can we print notepad data to excel sheet through selenium?

Ответить
@jaiganeshacharya1198
@jaiganeshacharya1198 - 08.09.2020 08:47

Sir, how we can count the words/character from text file ?

Ответить
@travelvlogs9050
@travelvlogs9050 - 07.08.2020 22:04

I have one question , assume the text file contains multiple paragraphs in it . I want to get only the 5 th paragraph text of that file ,not the complete text inside the file . Can u please suggest on this

Ответить
@aishwaryahr3252
@aishwaryahr3252 - 19.04.2020 07:05

Sir . .how can we print the output on the label...or like displaying some text on GUI.

Ответить
@rajendramahapatra3293
@rajendramahapatra3293 - 23.10.2019 05:02

There is one more approach
File file = new File(FilePath);
FileInputStream stream = new FileInputStream(file);
InputStreamReader reader = new InputStreamReader(stream);
BufferedReader br = new BufferedReader(reader);
String str;
while((str=br.readLine())!=null){
System.out.println(str);
}
br.close();

Ответить