我有字符串日期和我希望inceament日期为1,它应该循环直到月底.作为考试,如果我采取2010年11月它应该循环30天.如果我采取2010年12月它应该循环31天.下面显示我的代码......
String date="12/01/2010";
String incDate;
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(date));
for(int co=0; co<30; co++){
c.add(Calendar.DATE, 1);
incDate = sdf.format(c.getTime());
}
Run Code Online (Sandbox Code Playgroud) 当我使用Java读取文本文件时,如何跳过文本文件的前三行?
目前的节目,
public class Reader {
public static void main(String[] args) {
BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream("sample.txt")));
Map<String, Integer> result = new LinkedHashMap<String, Integer>();
Map<String, Integer> result2 = new LinkedHashMap<String, Integer>();
while (reader.ready()) {
String line = reader.readLine();
//split a line with spaces
String[] values = line.split("\s+");
//set a key date\tanimal
String key = values[0] + "\t" + values[1];
int sum = 0;
int count = 0;
//get a last counter and sum
if …Run Code Online (Sandbox Code Playgroud) public class Reader {
public static void main(String[] args) throws IOException, ParseException {
BufferedReader reader;
String animalName="cat";
String animal = null;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream("C:/dila.txt")));
Map<String, Integer> result = new LinkedHashMap<String, Integer>();
Map<String, Integer> result2 = new LinkedHashMap<String, Integer>();
while (reader.ready()) {
String line = reader.readLine();
/split a line with spaces/
String[] values = line.split(",");
String key = null;
if(values[1].compareTo(animalName)==0){
key = values[0];
animal=""+values[1].compareTo(animalName);
int sum = 0;
int count = 0;
/get a last …Run Code Online (Sandbox Code Playgroud)