search
HomeSoftware TutorialOffice SoftwareHow to read document content and display it in Label tag in Java

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!

Statement
This article is reproduced at:Excel办公网. If there is any infringement, please contact admin@php.cn delete
How to make a histogram in ExcelHow to make a histogram in ExcelApr 22, 2025 am 10:33 AM

This tutorial explores three distinct methods for creating histograms in Excel: leveraging the Analysis ToolPak's Histogram tool, employing the FREQUENCY or COUNTIFS functions, and utilizing PivotCharts. While creating basic charts in Excel is strai

Outlook signature: how to make, add and changeOutlook signature: how to make, add and changeApr 22, 2025 am 09:54 AM

This comprehensive guide provides step-by-step instructions for creating and managing professional email signatures in Microsoft Outlook. Learn how to craft compelling signatures with images, clickable links, and more, across all Outlook versions (i

Excel SUM formula to total a column, rows or only visible cellsExcel SUM formula to total a column, rows or only visible cellsApr 22, 2025 am 09:17 AM

This tutorial demonstrates how to calculate sums in Excel using the AutoSum feature and custom SUM formulas for columns, rows, and selected ranges. It also covers summing only visible cells, calculating running totals, summing across multiple sheets

How to AutoSum in ExcelHow to AutoSum in ExcelApr 22, 2025 am 09:05 AM

This concise guide explains Excel's AutoSum feature and its efficient uses. Learn to quickly sum columns, rows, or visible cells, and troubleshoot common AutoSum issues. Excel's SUM function is incredibly popular, prompting Microsoft to include a ded

Excel Switch function – the compact form of nested IF statementExcel Switch function – the compact form of nested IF statementApr 22, 2025 am 09:04 AM

This article introduces the Excel SWITCH function, explaining its syntax and demonstrating its use in simplifying complex nested IF statements. If you've struggled with lengthy nested IF formulas, the SWITCH function offers a significant time-saving

How to do a running total in Excel (Cumulative Sum formula)How to do a running total in Excel (Cumulative Sum formula)Apr 21, 2025 am 11:16 AM

This concise guide demonstrates how to efficiently calculate running totals (cumulative sums) in Excel using a SUM formula with strategically placed absolute and relative cell references. A running total displays the accumulated sum of a dataset as

Excel LEN function: count characters in cellExcel LEN function: count characters in cellApr 21, 2025 am 10:10 AM

Are you looking for an Excel formula to count characters in a cell? If so, then you have certainly landed up on the right page. This short tutorial will teach you how you can use the LEN function to count characters in Excel, with or with

How to count words in Excel - formula examplesHow to count words in Excel - formula examplesApr 21, 2025 am 09:59 AM

This tutorial demonstrates how to count words in Excel using a combination of the LEN, SUBSTITUTE, and TRIM functions. It offers both case-sensitive and case-insensitive formulas for counting total words or specific words/text within a cell or range

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.