How to read document content and display it in Label tag in Java

WBOY
Release: 2024-01-25 12:06:06
forward
1236 people have browsed it

How to read document content and display it in Label tag in Java

How does Java read the content in the document and display it in the Label tag

I have studied software development before, but it has been a while since I wrote code. If you ask me to write code for you and something goes wrong, I probably won't be able to fix it. Each software development language has its own way of writing, so it doesn't make much sense for me to change from Java to C, and then from C to iOS, because I am not familiar with them.

So here are some ideas for you:

1: Find R6

2: Read from R6 onward, and save while reading. For example, if you write an array, write a line into the array before reading a line (java reads by line, I remember it seems... )

3,: After each reading, judge whether the last character of each line is equal to the sign. If not, continue, if so, end reading (write a loop here, and jump out of the loop when the equal sign is read)

4: Finally, just take out the contents of the array and output them

Writing this thing in every language, the syntax will change but the idea will not. As for the specific code, you can find it all by looking through the book

I wish you learn JAVA well

Java implementation: How to read a text and read the file content through the file path inside

public class Test {

public static void main(String[] args) {

readFileByChars("d://test.txt");

}

public static void readFileByChars(String fileName) {

File file = new File(fileName);

Reader reader = null;

try {

if (file!=null) {

//Read multiple characters at one time

char[] tempchars = new char[30];

int charread = 0;

reader = new InputStreamReader(new FileInputStream(fileName));

// Read multiple characters into the character array, charread is the number of characters read at one time

while ((charread = reader.read(tempchars)) != -1) {

// Also block \r and do not display

if ((charread == tempchars.length)

& (tempchars[tempchars.length - 1] != '\r')) {

System.out.print(tempchars);

} else {

for (int i = 0; i

if (tempchars[i] == '\r') {

continue;

} else {

System.out.print(tempchars[i]);

}

}

}

}

}

} catch (Exception e1) {

e1.printStackTrace();

} finally {

if (reader != null) {

try {

reader.close();

} catch (IOException e1) {

System.out.println("File does not exist");

}

}

}

}

}

The above is the detailed content of How to read document content and display it in Label tag in Java. For more information, please follow other related articles on the PHP Chinese website!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!