Rabu, 01 April 2015

Cara Mengeksport Teks di Java

hai sahabat blogger! ada lagi nih koding bahasa java. kali ini kodingnya nggak berhubungan dengan tampilan, tapi lebih aplikatif sahabat blogger. pernahkah sahabat blogger membuat sebuah program dalam bahasa java untuk menampilkan string? nah biasanya kan program hanya akan menampilkan teks dalam command window. nah, bagaimana kalau mencetak teks tersebut di cetak pada file document baru. teks tersebut di eksport ke dalam file yang isinya teks tersebut. tanpa basa-basi lagi langsung saja lihat kodingnya. semoga bermanfaat. terima kasih !!
import java.io.*;

public class cetak {

    public static void main(String[] args) {

        try {
            String str = "SomeMoreTextIsHere";
            File newTextFile = new File("F:/thetextfile.txt");

            FileWriter fw = new FileWriter(newTextFile);
            fw.write(str);
            fw.close();

        } catch (IOException iox) {
            //do stuff with exception
            iox.printStackTrace();
        }
    }
}

Selasa, 31 Maret 2015

Membuat Game Acak Angka Menggunakan Bahasa Java


Halo sahabat blogger yang suka ngoding. ini ada sedikit koding dari saya untuk membuat game random number. silahkan kalo mau dicoba. biar cepat copas langsung terus jalankan programnya. semoga bermanfaat. terima kasih
/*
 * 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.
 */

/**
 *
 * @author yasir
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class RandomGame extends JFrame{
    int RandomNum, Guess;
    private JButton button;
    private JTextField textfield;
    private JLabel label;
    private JLabel promptlabel;
    private JLabel resultlabel;
    private JLabel randomlabel;
   
   
    public RandomGame(){
        setLayout(new FlowLayout());
    promptlabel= new JLabel("Please enter your random number 1-10 :");
    add(promptlabel);
   
    textfield = new JTextField(5);
    add(textfield);
   
    button = new JButton("Guess");
    add(button);
   
    resultlabel= new JLabel("");
    add(resultlabel);
   
    randomlabel= new JLabel("");
    add(randomlabel);
   
    event e = new event();
    button.addActionListener(e);
   
   
   
    }
    public class event implements ActionListener{
   
    public void actionPerformed(ActionEvent e){
        RandomNum = (int)(Math.random()*10+1);
               
                try{
                Guess=(int)(Double.parseDouble(textfield.getText()));
                if(Guess==RandomNum){
                    resultlabel.setText("You are the win");
                                    }
                else if(Guess!=RandomNum){
                    resultlabel.setText("You are the lost in the game");
                }
                resultlabel.setText("the random number generated was : "+RandomNum);;
               
                }
                catch(Exception ex){
                randomlabel.setText("Please enter only the number");
                }
               
       
    }
}
    public static void main(String args[]){
        RandomGame gui = new RandomGame();
       
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.setVisible(true);
        gui.setTitle("Random Game");
        gui.setSize(300,300);
    }
}

CARA MEMBUAT TAMPILAN MENU DI JAVA


Halo sahabat blogger. Saya ada sedikit koding nih bagi sahabat blogger yang suka ngoding menggunakan bahasa java. Supaya nggak bingung lagi. tinggal copas aja kodingnya terus dijalankan programnya. Mudah- mudahan bisa bermanfaat. terima kasih
/**
 *
 * @author yasir
 */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class menuTutorial extends JFrame{
    JMenu file;
    JMenuBar menuBar;
    JMenuItem exit;
 
    public menuTutorial(){
    setLayout(new FlowLayout());
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
 
    file = new JMenu("Menu");
    menuBar.add(file);
 
    exit = new JMenuItem("Exit");
    file.add(exit);
 
    event e = new event();
    exit.addActionListener(e);
 
    }
    public class event implements ActionListener{
        public void actionPerformed(ActionEvent e){
        System.exit(0);
        }
 
    }
    public static void main(String args[]){
    menuTutorial gui = new menuTutorial();
 
    gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    gui.setSize(200,200);
    gui.setVisible(true);
    gui.setTitle("menu");
    }
}


Jumat, 13 Februari 2015

Life in the city


Life in the is full of activity. Early in the morning hundreds of people rush out of their homes in the manner ants do when their nest is broken. Soon the streets are full of traffic. Shops and office open, students flock to their schools and the day’s work begin. The city now throb with activity. And it is full of noise. Hundreds of sight-seers, tourist, and other visit many place of interest in the city while businessmen from various parts of the world arrives to transact business.
Then towards evening, the officer, and day schools begin to close. Many of the shops too close. There is now a rush for buses and other means of transport. Everyone seems to be in a hurry to reach home. As a result of this rush, many accidents occur. One who has not been to the city before find it hard to move about at this time. Soo, however, there is almost no activity in several parts of city. These parts are usually the bussines centres.
With the coming of night, another kind of activity begins. The streets are now full of colourful lights. The air is cooler and life becomes more leisurely. People now seek entertainment. Many visit the cinemas, park and clubs, while other remains indoor to watch television or listen to the radio. Some visit friends and relatives and some spend their time reading books and megazines. Those are interested in politics discuss the latest political development. At the same time, hundreds of crimes are committed. Thieves and robbers who wait for the coming of night becomes active, and misfortune descends upon many. For the greed of a few, many are killed, and some live in constant fear. To bring criminal in the justice, the officer of the law are always on the move.
Workers and other who seek advancement in their careers attend educational institutions which are open till late in the night. Hundreds of them sit for  various examinations every year. The facilities and the opportunities that the people in the city have to further  their studies and uncrease their knowledge of human affairs are indeed many. As a result, the people in the city are usually better informed than those of village, where even a newspaper are sometimes difficult to get.

The city could, therefore, be describe as a place of ceaseless activity. Here, the drama of life is everyday.

Senin, 17 November 2014

Menentukan Jenis Bilangan Genap atau Ganjil

Menentukan Jenis Bilangan Genap atau Ganjil

bagi sahabat blogger yang belum ngerti cara membuat program mencari bilangan genap atau ganjil menggunakan bahasa C, Aku ingin berbagi cara membuatnya. Aku udah buat kodingnya nih di bawah ini. bagi sahabat blogger yang mau mencobanya tinggal menyalin kodingnya. kemudian pastekan di IDE bahasa C anda. terserah pake IDE yang mana karena hasilnya akan sama saja. kalau aku pakai codeblocks. setelah di salin, di simpan dengan format C kemudian di kompile dan run.
/* program untuk mencari jenis bilangan
genap atau ganjil*/

#include<stdio.h>

int main(){

int angka;

printf("masukkan angka:");
scanf("%d", &angka);

if(angka%2==0)
printf("bilangan anda genap");
else
printf("bilangan anda adalah bilangan ganjil");
return 0;
}

maka output yang didapatkan adalah seperti gambar dibawah ini

gambar untuk bilangan ganjil

gambar untuk bilangan genap

Rabu, 29 Oktober 2014

Perintah Manajemen User


Perintah Manajemen User Linux

Perintah Manajemen user di linux adalah segala perintah yang berhubungan dengan pengelolaan user di linux. Sekenario paling pas untuk manajemen user adalah pada webhosting atau lab komputer di kampus TI. Secara umum, manajemen user terdiri dari tiga hal utama yaitu
  1. Membuat user baru.
  2. Mengganti password.
  3. Menghapus user .

membuat user baru

gunakan perintah useradd
sudo useradd -m yasir_cesc -p rahasia

parameter -m artinya abdullah secara otomatis mempunyai “my dokument” di /home/yasir_cesc. parameter -p artinya passwordnya rahasia. Perintah lain untuk membuat user di linux adalah useradd. Perbedaannya, useradd bersifat interaktif.

Mengganti password

Password bisa diganti oleh user itu sendiri atau oleh admin.
diganti oleh admin
sudo passwd yasir_cesc 
diganti oleh user
passwd

Menghapus user

Untuk menghapus user gunakan perintah userdel
sudo userdel -r yasir_cesc 
opsi -r artinya file dokumen punya abdullah juga ikut terhapus saat user dihapus. Jika anda hanya ingin menghapus usernya saja, jangan gunakan parameter -r. cukup seperti ini
sudo userdel yasir_cesc
Selain ketiga hal diatas, sebenarnya masih ada beberapa perintah lain, namun perintah lain tidak terlalu penting. Sekedar info saja, beberapa perintah tambahan untuk manajemen user yaitu
  1. addgroup Menambahkan user ke group tertentu.
  2. users Melihat semua user yang sedang login.
Selamat mencoba!

Cara Mengatasi Error pada kali linux


Linux berbeda dengan windows dari berbagai sisinya. Salah satu hal yang berbeda adalah struktur direktorinya. Di Windows, 3 direktori utama adalah direktori user, windows dan program files. Di Linux, ada banyak direktori yang mempunyai tugas yang berbeda. Sebagian besar distro Linux, UNIX dan BSD mempunyai struktur direktori yang sama atau mirip. Mari kita tulusuri satu persatu apa sih isi masing masing direktori .
Linux berbeda dengan windows dari berbagai sisinya. Salah satu hal yang berbeda adalah struktur direktorinya. Di Windows, 3 direktori utama adalah direktori user, windows dan program files. Di Linux, ada banyak direktori yang mempunyai tugas yang berbeda. Sebagian besar distro Linux, UNIX dan BSD mempunyai struktur direktori yang sama atau mirip. Mari kita tulusuri satu persatu apa sih isi masing masing direktori .
diagram linux filesystem

sumber:http://www.winlinhack.com

/boot

direktori boot berisi kernel linux serta file bantunya. Jadi jika kita ditanya dimana kernel linux berada? dia ada didalam folder boot dengan nama vmlinux-x.y.z.

/bin,/sbin

berisi perintah dasar untuk user biasa. sedangkan folder /sbin berisi perintah untuk user root atau administrator.

/dev

Berisi file file yang merepresentasikan hardware.

/cdrom, /media, /mnt

Tiga folder ini mempunyai fungsi sama, yaitu menampung file dari usb,cdrom atau HD external saat anda menghubungkan device tadi ke linux. masing masing distro mempunyai kebijakan yang berbeda dalam hal ini.

/home, /root

Berisi dokumen dari user. folder ini bisa disamakan dengan my dokumen di windows. khusus untuk user root, letak “my dokumen”nya ada di folder /root.

/lib

lib berisi librari sofware dan kernel.file yang ada di folder ini biasanya berektensi so. file SO bisa disamakan dengan file DLL di windows.

/etc

berisi file konfigurasi di linux. bisa disamakan dengan registry di windows. jangan mengutak atik file di folder /etc jika anda tidak tahu persis apa yang anda lakukan.

/srv, /run

berisi file file untuk server. misalkan server menjalakan samba dan webserver, maka kebanyakan filenya ada disini.

/var

berisi file file untuk webserver /var/www. Folder ini juga berisi file log yang letaknya di /var/log.

/usr/, /opt

folder ini berisi program program yang terinstall di linux. dua folder ini bisa disamakan dengan “Program files” di Windows.

/tmp

hanya berisi file file sementara (temporer), isi folder ini hilang saat komputer direstart.

/proc

Berisi proses yang sedang berjalan. Setiap program yang sedang berjalan, maka proses tersebut ada di dalam folder /proc. isi file /proc juga hilang saat komputer di restart.

Sample Text

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)

Your email address is safe with us!

Translate

Facebook

Popular Topics

Popular Posts