Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Badguy13 Badguy13 is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 399
Rep Power: 14
Badguy13 mempunyai hidup yang Normal
Default [HELP]Mau Tanya Java

gini gan...

ane punya kodingan kyk gini..


Spoiler for Baca.Java:





Quote:





package JISMC;



import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.FileNotFoundException;

import java.io.IOException;



public class Baca {

static char spasi;

public static void main(String[] args) {

File file = new File("d:/test.txt");

StringBuffer contents = new StringBuffer();

BufferedReader reader = null;



try {

reader = new BufferedReader(new FileReader(file));

String text = null;

// ulangi sampai semua baris terbaca



while ((text = reader.readLine()) != null) {

contents.append(text).append(System.getProperty("l ine.separator"));





}

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

if (reader != null) {

reader.close();

}

} catch (IOException e) {

e.printStackTrace();

}

}



// tampilkan isi file

System.out.println(contents.toString());

}

}















nah diatas kan ada file test.txt

filenya isinya ginian


Spoiler for test.txt:





Quote:





1 0.002188 0.000000 0.000000 0.620521

2 0.002917 0.315417 0.188854 0.004440

3 0.000313 0.009825 0.008978 0.663125

4 0.111667 0.123855 0.078230 0.663125













ane punya array[i][j]

dengan i = indeks data 1,2,3,4

dan j = indeks data 0.00 dst

pertanyaannya....gmn ya supaya angka di test.txt bs masuk ke var array...

tolong bgt ya agan2...

penting bgt sebabnya ini...

thx before..



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 10:37 AM.


no new posts