精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網站建設資訊

NEWS

網站建設資訊

包含500行的代碼java的詞條

一個java文件里面最多寫多少行代碼?

hotspot 虛擬機(咱們平時開發用的sun公司的虛擬機,其他兩大商用虛擬機是BEA的JRockit和IBM的J9)里面兩個字節來限制大小,所以最多65536行,超過javac會無法編譯。而且一個Java方法不能超過64k。一般一個Java類不要有太多行數,如果一個Java代碼超過幾千甚至過萬,個人覺得應該考慮一些代碼優化方式,比如繼承;或者重新構思這個類。代碼行數太多可讀性查,不利于維護。

綏化網站建設公司創新互聯公司,綏化網站設計制作,有大型網站制作公司豐富經驗。已為綏化成百上千提供企業網站建設服務。企業網站搭建\成都外貿網站建設公司要多少錢,請找那個售后服務好的綏化做網站的公司定做!

求java小程序代碼,500行左右。。大作業用。追加50

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

class mypanel extends Panel implements MouseListener

{

int chess[][] = new int[11][11];

boolean Is_Black_True;

mypanel()

{

Is_Black_True = true;

for(int i = 0;i 11;i++)

{

for(int j = 0;j 11;j++)

{

chess[i][j] = 0;

}

}

addMouseListener(this);

setBackground(Color.BLUE);

setBounds(0, 0, 360, 360);

setVisible(true);

}

public void mousePressed(MouseEvent e)

{

int x = e.getX();

int y = e.getY();

if(x 25 || x 330 + 25 ||y 25 || y 330+25)

{

return;

}

if(chess[x/30-1][y/30-1] != 0)

{

return;

}

if(Is_Black_True == true)

{

chess[x/30-1][y/30-1] = 1;

Is_Black_True = false;

repaint();

Justisewiner();

return;

}

if(Is_Black_True == false)

{

chess[x/30-1][y/30-1] = 2;

Is_Black_True = true;

repaint();

Justisewiner();

return;

}

}

void Drawline(Graphics g)

{

for(int i = 30;i = 330;i += 30)

{

for(int j = 30;j = 330; j+= 30)

{

g.setColor(Color.WHITE);

g.drawLine(i, j, i, 330);

}

}

for(int j = 30;j = 330;j += 30)

{

g.setColor(Color.WHITE);

g.drawLine(30, j, 330, j);

}

}

void Drawchess(Graphics g)

{

for(int i = 0;i 11;i++)

{

for(int j = 0;j 11;j++)

{

if(chess[i][j] == 1)

{

g.setColor(Color.BLACK);

g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);

}

if(chess[i][j] == 2)

{

g.setColor(Color.WHITE);

g.fillOval((i + 1) * 30 - 8, (j + 1) * 30 - 8, 16, 16);

}

}

}

}

void Justisewiner()

{

int black_count = 0;

int white_count = 0;

int i = 0;

for(i = 0;i 11;i++)//橫向判斷

{

for(int j = 0;j 11;j++)

{

if(chess[i][j] == 1)

{

black_count++;

if(black_count == 5)

{

JOptionPane.showMessageDialog(this, "黑棋勝利");

Clear_Chess();

return;

}

}

else

{

black_count = 0;

}

if(chess[i][j] == 2)

{

white_count++;

if(white_count == 5)

{

JOptionPane.showMessageDialog(this, "白棋勝利");

Clear_Chess();

return;

}

}

else

{

white_count = 0;

}

}

}

for(i = 0;i 11;i++)//豎向判斷

{

for(int j = 0;j 11;j++)

{

if(chess[j][i] == 1)

{

black_count++;

if(black_count == 5)

{

JOptionPane.showMessageDialog(this, "黑棋勝利");

Clear_Chess();

return;

}

}

else

{

black_count = 0;

}

if(chess[j][i] == 2)

{

white_count++;

if(white_count == 5)

{

JOptionPane.showMessageDialog(this, "白棋勝利");

Clear_Chess();

return;

}

}

else

{

white_count = 0;

}

}

}

for(i = 0;i 7;i++)//左向右斜判斷

{

for(int j = 0;j 7;j++)

{

for(int k = 0;k 5;k++)

{

if(chess[i + k][j + k] == 1)

{

black_count++;

if(black_count == 5)

{

JOptionPane.showMessageDialog(this, "黑棋勝利");

Clear_Chess();

return;

}

}

else

{

black_count = 0;

}

if(chess[i + k][j + k] == 2)

{

white_count++;

if(white_count == 5)

{

JOptionPane.showMessageDialog(this, "白棋勝利");

Clear_Chess();

return;

}

}

else

{

white_count = 0;

}

}

}

}

for(i = 4;i 11;i++)//右向左斜判斷

{

for(int j = 6;j = 0;j--)

{

for(int k = 0;k 5;k++)

{

if(chess[i - k][j + k] == 1)

{

black_count++;

if(black_count == 5)

{

JOptionPane.showMessageDialog(this, "黑棋勝利");

Clear_Chess();

return;

}

}

else

{

black_count = 0;

}

if(chess[i - k][j + k] == 2)

{

white_count++;

if(white_count == 5)

{

JOptionPane.showMessageDialog(this, "白棋勝利");

Clear_Chess();

return;

}

}

else

{

white_count = 0;

}

}

}

}

}

void Clear_Chess()

{

for(int i=0;i11;i++)

{

for(int j=0;j11;j++)

{

chess[i][j]=0;

}

}

repaint();

}

public void paint(Graphics g)

{

Drawline(g);

Drawchess(g);

}

public void mouseExited(MouseEvent e){}

public void mouseEntered(MouseEvent e){}

public void mouseReleased(MouseEvent e){}

public void mouseClicked(MouseEvent e){}

}

class myframe extends Frame implements WindowListener

{

mypanel panel;

myframe()

{

setLayout(null);

panel = new mypanel();

add(panel);

panel.setBounds(0,23, 360, 360);

setTitle("單人版五子棋");

setBounds(200, 200, 360, 383);

setVisible(true);

addWindowListener(this);

}

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

public void windowDeactivated(WindowEvent e){}

public void windowActivated(WindowEvent e){}

public void windowOpened(WindowEvent e){}

public void windowClosed(WindowEvent e){}

public void windowIconified(WindowEvent e){}

public void windowDeiconified(WindowEvent e){}

}

public class mywindow

{

public static void main(String argc [])

{

myframe f = new myframe();

}

}

一個java管理系統多少行代碼

1,java規范中一般不建議一個java類中超過500行

2,一行的長度不超過200個

3,按照規定格式將代碼格式化

需要一份500行的java程序,期末大作業,最好帶詳細注釋。

Java生成CSV文件簡單操作實例

CSV是逗號分隔文件(Comma Separated Values)的首字母英文縮寫,是一種用來存儲數據的純文本格式,通常用于電子表格或數據庫軟件。在 CSV文件中,數據“欄”以逗號分隔,可允許程序通過讀取文件為數據重新創建正確的欄結構,并在每次遇到逗號時開始新的一欄。如:

123? ?1,張三,男2,李四,男3,小紅,女? ?

Java生成CSV文件(創建與導出封裝類)

package com.yph.omp.common.util;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Iterator;

import java.util.LinkedHashMap;

import java.util.List;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;

import org.junit.Test;

/**

* Java生成CSV文件

*/

public class CSVUtil {

/**

* 生成為CVS文件

*

* @param exportData

*? ? ? ? ? ? 源數據List

* @param map

*? ? ? ? ? ? csv文件的列表頭map

* @param outPutPath

*? ? ? ? ? ? 文件路徑

* @param fileName

*? ? ? ? ? ? 文件名稱

* @return

*/

@SuppressWarnings("rawtypes")

public static File createCSVFile(List exportData, LinkedHashMap map,

String outPutPath, String fileName) {

File csvFile = null;

BufferedWriter csvFileOutputStream = null;

try {

File file = new File(outPutPath);

if (!file.exists()) {

file.mkdir();

}

// 定義文件名格式并創建

csvFile = File.createTempFile(fileName, ".csv",

new File(outPutPath));

// UTF-8使正確讀取分隔符","

csvFileOutputStream = new BufferedWriter(new OutputStreamWriter(

new FileOutputStream(csvFile), "GBK"), 1024);

// 寫入文件頭部

for (Iterator propertyIterator = map.entrySet().iterator(); propertyIterator

.hasNext();) {

java.util.Map.Entry propertyEntry = (java.util.Map.Entry) propertyIterator

.next();

csvFileOutputStream

.write("\"" + (String) propertyEntry.getValue() != null ? (String) propertyEntry

.getValue() : "" + "\"");

if (propertyIterator.hasNext()) {

csvFileOutputStream.write(",");

}

}

csvFileOutputStream.newLine();

// 寫入文件內容

for (Iterator iterator = exportData.iterator(); iterator.hasNext();) {

Object row = (Object) iterator.next();

for (Iterator propertyIterator = map.entrySet().iterator(); propertyIterator

.hasNext();) {

java.util.Map.Entry propertyEntry = (java.util.Map.Entry) propertyIterator

.next();

/*-------------------------------*/ 

//以下部分根據不同業務做出相應的更改

StringBuilder sbContext = new StringBuilder("");

if (null != BeanUtils.getProperty(row,(String) propertyEntry.getKey())) {

if("證件號碼".equals(propertyEntry.getValue())){

//避免:身份證號碼 ,讀取時變換為科學記數 - 解決辦法:加 \t(用Excel打開時,證件號碼超過15位后會自動默認科學記數)

sbContext.append(BeanUtils.getProperty(row,(String) propertyEntry.getKey()) + "\t");

}else{

sbContext.append(BeanUtils.getProperty(row,(String) propertyEntry.getKey()));? ? ? ? ? ? ? ? ? ? ? ? ?

}

}

csvFileOutputStream.write(sbContext.toString());

/*-------------------------------*/? ? ? ? ? ? ? ? ?

if (propertyIterator.hasNext()) {

csvFileOutputStream.write(",");

}

}

if (iterator.hasNext()) {

csvFileOutputStream.newLine();

}

}

csvFileOutputStream.flush();

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

csvFileOutputStream.close();

} catch (IOException e) {

e.printStackTrace();

}

}

return csvFile;

}

/**

* 下載文件

*

* @param response

* @param csvFilePath

*? ? ? ? ? ? 文件路徑

* @param fileName

*? ? ? ? ? ? 文件名稱

* @throws IOException

*/

public static void exportFile(HttpServletRequest request,

HttpServletResponse response, String csvFilePath, String fileName)

throws IOException {

response.setCharacterEncoding("UTF-8");

response.setContentType("application/csv;charset=GBK");

response.setHeader("Content-Disposition", "attachment; filename="

+ new String(fileName.getBytes("GB2312"), "ISO8859-1"));

InputStream in = null;

try {

in = new FileInputStream(csvFilePath);

int len = 0;

byte[] buffer = new byte[1024];

OutputStream out = response.getOutputStream();

while ((len = in.read(buffer)) 0) {

out.write(buffer, 0, len);

}

} catch (FileNotFoundException e1) {

System.out.println(e1);

} finally {

if (in != null) {

try {

in.close();

} catch (Exception e1) {

throw new RuntimeException(e1);

}

}

}

}

/**

* 刪除該目錄filePath下的所有文件

*

* @param filePath

*? ? ? ? ? ? 文件目錄路徑

*/

public static void deleteFiles(String filePath) {

File file = new File(filePath);

if (file.exists()) {

File[] files = file.listFiles();

for (int i = 0; i files.length; i++) {

if (files[i].isFile()) {

files[i].delete();

}

}

}

}

/**

* 刪除單個文件

*

* @param filePath

*? ? ? ? ? ? 文件目錄路徑

* @param fileName

*? ? ? ? ? ? 文件名稱

*/

public static void deleteFile(String filePath, String fileName) {

File file = new File(filePath);

if (file.exists()) {

File[] files = file.listFiles();

for (int i = 0; i files.length; i++) {

if (files[i].isFile()) {

if (files[i].getName().equals(fileName)) {

files[i].delete();

return;

}

}

}

}

}

@SuppressWarnings({ "unchecked", "rawtypes" })

@Test

public void createFileTest() {

List exportData = new ArrayListMap();

Map row1 = new LinkedHashMapString, String();

row1.put("1", "11");

row1.put("2", "12");

row1.put("3", "13");

row1.put("4", "14");

exportData.add(row1);

row1 = new LinkedHashMapString, String();

row1.put("1", "21");

row1.put("2", "22");

row1.put("3", "23");

row1.put("4", "24");

exportData.add(row1);

LinkedHashMap map = new LinkedHashMap();

map.put("1", "第一列");

map.put("2", "第二列");

map.put("3", "第三列");

map.put("4", "第四列");

String path = "d:/export";

String fileName = "文件導出";

File file = CSVUtil.createCSVFile(exportData, map, path, fileName);

String fileNameNew = file.getName();

String pathNew = file.getPath();

System.out.println("文件名稱:" + fileNameNew );

System.out.println("文件路徑:" + pathNew );

}

}

//注:BeanUtils.getProperty(row,(String) propertyEntry.getKey()) + "\t" ,只為解決數字格式超過15位后,在Excel中打開展示科學記數問題。


當前文章:包含500行的代碼java的詞條
網站地址:http://m.jcarcd.cn/article/hpejsp.html
主站蜘蛛池模板: 日本不卡2| 国产精品毛多多水多 | 国产区精品区自拍 | 91色蝌蚪在线 | 国产精品美女视视频 | 午夜福利电影影院 | 精品a在线观看 | 国产精品一区乱码在 | 韩国成人一区 | 国内综合精品午 | 国产精品色片免费 | 国产精品夫妻在线 | 91丝袜诱惑一 | 日韩午夜福利在线 | 国产精品青草综合久 | 国产人兽网址 | 91视频区| 韩国欧洲一级 | 国产黑丝视频 | 国产欧美日本亚洲 | 欧美在线专区 | 日本99成人免费 | 欧美一级在线观看 | 精品国产91在店 | 91香蕉国 | 国产大片好看免费 | 成人黄人一级 | 精品成人九九九 | 欧洲视频 | 日韩欧美在线不卡 | 欧美亚洲日韩国产 | 最新中文字幕第一页 | 日韩a草 | 国产不卡一区 | 91九色风韵老熟女 | 国产视频一区二区 | 国产最新电影在线观 | 国产在线视频色综合 | 99婷婷在线 | 国产女主播精 | 91国产最 |