Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
Java4Compiler
/
src
/
inputSystem
/
StdInHandler.java
Java4Compiler
/
src
/
inputSystem
/
StdInHandler.java
StdInHandler.java 1.69 KB
Copy Edit Raw Blame History
package inputSystem;
import java.util.Scanner;
/**
* @author Cherry
* @date 2022年1月19日
* @time 15:48
* @brief 从标准输入流中(控制台)中读入缓冲区
*/
public class StdInHandler implements FileHandler {
//接收所有输入的字符串,将所有语句连成一行字符串
public StringBuilder input_buffer = new StringBuilder();
//input_buffer当前指针位置
private int curPos = 0;
@Override
public void Open() {
Scanner sc = new Scanner(System.in);
while (true) {
String line = sc.nextLine();
if (line.equals("end")) {
break;
}
input_buffer.append(line); //StringBuilder线程不安全,但性能高于StringBuffer
input_buffer.append('\n'); //**每一行后面加上换行符
}
//sc.close(); //一次输入完就关闭输入流
}
@Override
public int Close() {
return 0;
}
/**
* 从 input_buffer 中读数据到缓冲区
* @param buf 缓冲区 Start_buf
* @param begin 缓冲区写入的起始地址
* @param len 缓冲区要写入字符的长度
* @return 返回实际上写入的字符数量
*/
@Override
public int Read(byte[] buf, int begin, int len) {
int readCnt = 0; //实际上读取的字符数量
if (curPos >= input_buffer.length()) {
return 0;
}
byte[] inputBuf = input_buffer.toString().getBytes();
//当已经读取的字符串长度小于要求读取的长度 且 已经读取的长度小于输入流中剩余的长度
while (readCnt < len && curPos + readCnt < input_buffer.length()) {
buf[begin + readCnt] = inputBuf[curPos + readCnt];
readCnt++;
}
curPos = curPos + readCnt;
return readCnt;
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

实现C语言的简易编译器,并将C语言转换成字节码运行在Java虚拟机中
Cancel

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/cherry05/Java4Compiler.git
git@gitee.com:cherry05/Java4Compiler.git
cherry05
Java4Compiler
Java4Compiler
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /