Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Java程式
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.sample;
- import java.io.File;
- import java.util.Scanner;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author 郭翔宇
- */
- public class ShowPrice100 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- try {
- int count = 0;
- File file = new File("data.txt");
- Scanner scanner = new Scanner(file);
- String input = "";
- while (scanner.hasNext()) {
- count = count + 1;
- System.out.printf("%04d.\t", count);
- input = scanner.nextLine();
- String input2[] = input.split(" ");
- for (int i = 0; i < 5; i++) {
- System.out.printf("%.0f\t", Double.parseDouble(input2[i]));
- }
- System.out.printf("\n");
- }
- scanner.close();
- } catch (Exception ex) {
- System.out.println(ex);
- Logger.getLogger(ShowPrice100.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- /*
- data.txt
- 200306030 37.1 37.4 36.92 37.08
- 20030701 37.09 38.1 37.09 38.05
- 20030702 38.17 38.82 38.1 38.69
- 20030703 40.6 40.6 38.81 39
- 20030704 39.1 39.26 38.75 39.26
- 201901018 75.75 76.1 75.4 75.95
- 201901021 76.35 76.7 76.25 76.5
- 201901021 76.35 76.7 76.25 76.5
- 201901021 76.35 76.7 76.25 76.5
- 201901021 76.35 76.7 76.25 76.5
- */
- /*
- Mion He
- 5 小時
- 請教各位前輩,我用java 8在class建立了二為陣列:3867列,5欄,可是為什麼印出陣列長度卻只有1002?
- 跑迴圈時用length只能印出一部分資料,設定長度時也只印一部分且出現C:\\Users\\user\\AppData\\Local\\NetBeans\\Cache\\8.2\\executor-snippets\\run.xml:53: Java returned: 1。
- 想請問前輩們這是發生什麼事?
- https://www.facebook.com/groups/1403852566495675/permalink/2265069293707327/
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement