📄 util.java
字号:
package com.bemjh.util;
import com.bemjh.Shape.CarShape;
import com.bemjh.Shape.ShapeIcon;
import javax.swing.JOptionPane;
import javax.swing.Icon;
import java.util.Vector;
/**
* Created by IntelliJ IDEA.
* User: ma
* Date: 2006-11-24
* Time: 21:41:44
* To change this template use File | Settings | File Templates.
*/
public class Util {
public static void showMessageDialog(String title,String content, Icon icon){
JOptionPane.showMessageDialog(null,content,title,0,icon);
}
/**
* This method will read lines from a CSV file,
* line by line. Each time that this method is
* called an array of strings is returned that
* contains all of the fields read from that
* line.
*
* @param r A BufferedReader to read the CSV from,
* line by line.
* @return An array of fields read from one line
* of the CSV file.
*/
public static String[] parseCSVLine(String str)
{
String rtn;
boolean quote = false;
int i;
Vector vec = new Vector();
// if its null we have reached the end
if ( str==null )
return null;
// now loop through this line
rtn = "";
for ( i=0;i<str.length();i++ ) {
if ( str.charAt(i)=='\"' ) {
// found a ", check to see if
// there is a second one
if ( (i+1)<str.length()&&
(str.charAt(i+1)=='\"') ) {
// found a "" so just insert a single "
rtn+="\"";
i++;
continue;
}
// toggle quote mode
quote=!quote;
} else if ( (str.charAt(i)==',') &&
(!quote) ) {
// found a comma and we're not in quote mode
vec.addElement(rtn);
rtn = "";
} else {
// append character
rtn+=str.charAt(i);
}
}
// add in the last element, if present
if ( rtn.length()>0 )
vec.addElement(rtn);
// create an array
String arr[] = new String[vec.size()];
vec.copyInto(arr);
return arr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -