学习java没有多久,一直不知道java如何实现像C的scanf一样可以提示输入一个值,然后返回一个想要的结果。
最近一直在做关于远程FTP操作的功能模块,用的apache的FTPClient ,但是用它的上传方法一直不能在远程Browser上传文件,获取不到这个文件。于是想到了最传统的in/out流方式,于是乎~想到了类似于scanf的实现方法。
import java.io.*;
public class Year {
public static void main(String arge[]) throws IOException {
InputStreamReader ir;
BufferedReader in;
ir = new InputStreamReader(System.in);
in = new BufferedReader(ir);
System.out.println("输入年份是:");
String s = in.readLine();
//System.out.println("s==========" + s);
int year = Integer.parseInt(s);
if (year % 4 == 0 && year % 100
!= 0 || year % 400 == 0) {
System.out.println("" + year + "年是闰年.");
} else {
System.out.println("" + year + "年不是闰年..");
}
}
}
这是一段提示 输入年份 后通过计算返回 是否是闰年的代码,用到了InputStreamReader和BufferedReader

分享到:
相关推荐
Chapter 6: User Input: Getting Data in Runtime Chapter 7: The String Object Chapter 8: Boolean Logic Chapter 9: Loops and Arrays Chapter 10: Methods Chapter 11: Inheritance and Polymorphism Chapter 12...
Chapter 6: User Input: Getting Data in Runtime Chapter 7: The String Object Chapter 8: Boolean Logic Chapter 9: Loops and Arrays Chapter 10: Methods Chapter 11: Inheritance and Polymorphism Chapter 12...
be acquired by the user(s) through POP or IMAP. This does not require your SMTP server to be an open relay, as authentication is supported, but it is your responsibility to ensure the SMTP server is...
<title>Getting Started: Serving Web Content ; charset=UTF-8"/> <link rel="stylesheet" type="text/css" media="all" th:href="@{/css/user.css}"/> <form action="#" th:action="@{/user}" th:object="${...
For example, the employee registration module may require detailed design for user input validation, data storage, and error handling. After the design phase, the actual coding takes place, ...
1.1. Simplifying Java development 1.1.1. Unleashing the power of POJOs 1.1.2. Injecting dependencies 1.1.3. Applying aspects 1.1.4. Eliminating boilerplate code with templates 1.2. Containing your ...
User-Defined Java Counters 262 User-Defined Streaming Counters 266 Sorting 266 Preparation 266 Partial Sort 268 Total Sort 272 Secondary Sort 276 Joins 281 Map-Side Joins 282 Reduce-Side Joins 284 ...
<input type="text" id="username" name="username" required> 提交 document.getElementById('myForm').addEventListener('submit', function(event) { var username = document.getElementById('username')...
Chapter 6 Handling Input and Output Chapter 7 Operators Chapter 8 Trace Tables Chapter 9 Using NetBeans IDE Section 3 Sequence Control Structures Chapter 10 Introduction to Sequence Control ...
The Android User Interface Basic Widgets Debugging Your App The Classic Container Classes Other Common Widgets and Containers Tutorial #5 - Creating a Layout GUI Building, Continued AdapterViews and ...
Adding a Static Java Library 18 Android.mk Variables 18 Creating Release Keys and Signing Builds 26 In this document 26 Introduction 27 Generating keys 27 Signing a build for release 28 Customization ...
- **Getting Values into the Program**: Discussion on how to read values from external sources, such as keyboard input, and store them in variables. #### Writing a Program This section provides ...
Improving CPU Performance in Java Finding and Eliminating Jank Issues with Bandwidth Focus On: TrafficStats Measuring Bandwidth Consumption Being Smarter About Bandwidth Issues with Application Heap ...
Responding to User Input 671 Printing 675 Implementing Print and Print Preview 676 Summary 680 Part IV: Data 683 Chapter 21: Data Access with .NET 685 ADO.NET Overview 685 Namespaces 686 Shared ...
Handling input and output in Python involves reading from and writing to files, interacting with the user, and managing data formats. **2.7 Standard Library** The Python standard library provides a ...
9.4.5. Getting Dates and Date Parts 9.4.6. Working with Fractions of Seconds 9.4.7. Sunrise / Sunset 9.5. Creation of dates 9.5.1. Create the actual date 9.5.2. Create a date from database 9.5.3...
Check UserBehavior DB(Root Only)- Reads user Behavior monitoring database AppUsage UI - See app usage logs in UI CIQ APP UI - Attempts to open all known CIQ Activities Start HTCLoggers - Start HTC ...