JSON

Ê·ÉÏ×îÈ«µÄ Java ÐÂÊÖÎÊÌâ»ã×Ü(4)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2015-10-17 10:10 ÎÒÒªÆÀÂÛ( )

JavaÌṩÁËFileInputStreamÒÔ¼°FileOutputStreamÀàÀ´½øÐÐÎļþµÄ¶Áд²Ù×÷¡£FileInputStreamµÄ¹¹Ôì·½·¨»á½ÓÊÕÊäÈëÎļþµÄ·¾¶×÷ΪÈë²ÎÈ»ºó´´½¨³öÒ»¸öÎļþµÄÊäÈëÁ÷¡£Í¬ÑùµÄ£¬FileOutputStreamµÄ¹¹Ôì·½·¨Ò²»á½ÓÊÕÒ»¸öÎÄ

JavaÌṩÁËFileInputStreamÒÔ¼°FileOutputStreamÀàÀ´½øÐÐÎļþµÄ¶Áд²Ù×÷¡£FileInputStreamµÄ¹¹Ôì·½·¨»á½ÓÊÕÊäÈëÎļþµÄ·¾¶×÷ΪÈë²ÎÈ»ºó´´½¨³öÒ»¸öÎļþµÄÊäÈëÁ÷¡£Í¬ÑùµÄ£¬FileOutputStreamµÄ¹¹Ôì·½·¨Ò²»á½ÓÊÕÒ»¸öÎļþ·¾¶×÷ΪÈë²ÎÈ»ºó´´½¨³öÎļþµÄÊä³öÁ÷¡£ÔÚ´¦ÀíÍêÎļþÖ®ºó£¬Ò»¸öºÜÖØÒªµÄ²Ù×÷¾ÍÊÇÒª¼ÇµÃ¡±close¡±µôÕâЩÁ÷¡£

import java.io.*; public class myIODemo { public static void main(String args[]) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream("//home//user//Documents//InputFile.txt"); out = new FileOutputStream("//home//user//Documents//OutputFile.txt"); int c; while((c = in.read()) != -1) { out.write(c); } } finally { if(in != null) { in.close(); } if(out != null) { out.close(); } } } }ÔÚJavaÖÐÖ´ÐÐij¸öshellÃüÁî

JavaÌṩÁËRuntimeÀàÀ´Ö´ÐÐshellÃüÁî¡£ÓÉÓÚÕâЩÊÇÍⲿµÄÃüÁÒò´ËÒì³£´¦Àí¾ÍÏÔµÃÒì³£ÖØÒª¡£ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÎÒÃǽ«Í¨¹ýÒ»¸ö¼òµ¥µÄÀý×ÓÀ´ÑÝʾһÏ¡£ÎÒÃÇ»áÔÚshellÃüÁîÐÐÖдò¿ªÒ»¸öpdfÎļþ¡£

import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class ShellCommandExec { public static void main(String[] args) { String gnomeOpenCommand = "gnome-open //home//user//Documents//MyDoc.pdf"; try { Runtime rt = Runtime.getRuntime(); Process processObj = rt.exec(gnomeOpenCommand); InputStream stdin = processObj.getErrorStream(); InputStreamReader isr = new InputStreamReader(stdin); BufferedReader br = new BufferedReader(isr); String myoutput = ""; while ((myoutput=br.readLine()) != null) { myoutput = myoutput+"/n"; } System.out.println(myoutput); } catch (Exception e) { e.printStackTrace(); } } }ʹÓÃÕýÔò

ÕýÔò±í´ïʽµÄ½á¹¹ÕªÂ¼ÈçÏ£¨À´Ô´: Oracle¹ÙÍø£©

×Ö·û

x×Ö·ûx

/·´Ð±¸Ü

/0n8½øÖÆֵΪ0nµÄ×Ö·û(0<=n<=7)

/0nn

/0mnn8½øÖÆֵΪ0mnnµÄ×Ö·û(0 <= m <= 3, 0<=n<=7)

/xhh16½øÖÆֵΪ0xhhµÄ×Ö·û

/uhhhh16½øÖÆֵΪ0xhhhhµÄ×Ö·û

/x{h¡­h}16½øÖÆֵΪ0xh¡­hµÄ×Ö·û(Character.MINCODEPOINT <= 0xh¡­h <= Character.MAXCODEPOINT)

/tÖƱí·û(¡®/u0009¡ä)

/n»»Ðзû(¡®/u000A¡¯)

/r»Ø³µ(¡®/u000D¡¯)

/f·ÖÒ³·û(¡®/u000C¡¯)

/a¾¯¸æ·û(¡®/u0007¡ä)

/eESC(¡®/u001B¡¯)

/cxctrl+x

×Ö·û·ÖÀà

[abc]a, b»òc

[^abc]abcÒÔÍâµÄÈÎÒâ×Ö·û

[a-zA-Z]aµ½zÒÔ¼°Aµ½Z

[a-d[m-p]]aµ½d»òÕßmµ½p[a-dm-p]ÔòÊÇÈ¡²¢¼¯

[a-z&&[def]]d,e»òf(½»¼¯)

[ad-z]

[a-z&&[^bc]]aµ½zµ«²»°üÀ¨bºÍc

[a-z&&[^m-p]]aµ½zµ«²»°üÀ¨mp:Ò²¾ÍÊÇ[a-lq-z]

Ô¤¶¨Òå×Ö·û

.ÈÎÒâ×Ö·û£¬ÓпÉÄÜ°üÀ¨»»Ðзû

/d0µ½9µÄÊý×Ö

/D0µ½9ÒÔÍâµÄ×Ö·û

/s¿Õ¸ñ·û[ /t/n/x0B/f/r]

/S·Ç¿Õ¸ñ·û[^/s]

/w×Öĸ[a-zA-Z_0-9]

/W·Ç×Öĸ[^/w]

±ß½çÆ¥Åä

^ÐÐÊ×

$ÐÐÄ©

/bµ¥´Ê±ß½ç

/AÊäÈëµÄÆðʼλÖÃ

/GÇ°Ò»¸öÆ¥ÅäµÄĩβ

/ZÊäÈëµÄ½áÊøλÖ㬽öÓÃÓÚ×îºóµÄ½áÊø·û

/zÊäÈëµÄ½áÊøλÖÃ

import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexMatches { private static String pattern = "^[_A-Za-z0-9-]+(//.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(//.[A-Za-z0-9]+)*(//.[A-Za-z]{2,})$"; private static Pattern mypattern = Pattern.compile(pattern); public static void main( String args[] ){ String valEmail1 = "[email protected]"; String invalEmail1 = "....@domain.com"; String invalEmail2 = ".$$%%@domain.com"; String valEmail2 = "[email protected]"; System.out.println("Is Email ID1 valid? "+validateEMailID(valEmail1)); System.out.println("Is Email ID1 valid? "+validateEMailID(invalEmail1)); System.out.println("Is Email ID1 valid? "+validateEMailID(invalEmail2)); System.out.println("Is Email ID1 valid? "+validateEMailID(valEmail2)); } public static boolean validateEMailID(String emailID) { Matcher mtch = mypattern.matcher(emailID); if(mtch.matches()){ return true; } return false; } }Java SwingµÄ¼òµ¥Ê¾Àý

ÓÐÁËJavaµÄswing£¬Äã±ã¿ÉÒÔ±àдGUIÓ¦ÓÃÁË¡£JavaËùÌṩµÄjavax°üÖоͰüº¬ÁËswing¡£Ê¹ÓÃswingÀ´±àдGUI³ÌÐòÊ×ÏÈÐèÒª¼Ì³ÐÏÂJFrame¡£È»ºóÔÚÀïÃæÌí¼ÓBox£¬È»ºó±ã¿ÉÒÔÍùÀïÃæÌí¼ÓÖîÈç°´Å¥£¬¶àÑ¡°´Å¥£¬Îı¾¿òµÈ¿Ø¼þÁË¡£ÕâЩBoxÊÇ·ÅÔÚContainerµÄ×îÍâ²ãµÄ¡£

import java.awt.*; import javax.swing.*; public class SwingsDemo extends JFrame { public SwingsDemo() { String path = "//home//user//Documents//images"; Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); Box myHorizontalBox = Box. createHorizontalBox(); Box myVerticleBox = Box. createVerticalBox(); myHorizontalBox.add(new JButton("My Button 1")); myHorizontalBox.add(new JButton("My Button 2")); myHorizontalBox.add(new JButton("My Button 3")); myVerticleBox.add(new JButton(new ImageIcon(path + "//Image1.jpg"))); myVerticleBox.add(new JButton(new ImageIcon(path + "//Image2.jpg"))); myVerticleBox.add(new JButton(new ImageIcon(path + "//Image3.jpg"))); contentPane.add(myHorizontalBox); contentPane.add(myVerticleBox); pack(); setVisible(true); } public static void main(String args[]) { new SwingsDemo(); } }ʹÓÃJava²¥·ÅÒôƵ

ÔÚJavaÖУ¬²¥·ÅÒôƵÊÇÒ»¸öºÜ³£¼ûµÄÐèÇó£¬ÓÈÆäÊÇÔÚÓÎÏ·¿ª·¢ÀïÃæ¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • iOSÈëÃÅѧϰ(json½âÎö)

    iOSÈëÃÅѧϰ(json½âÎö)

    2016-01-26 09:00

  • iOSÖÐjson½âÎö³öÏÖµÄnull,nil,NSNumberµÄÎÊÌ⣬jsonnsnumber

    iOSÖÐjson½âÎö³öÏÖµÄnull,nil,NSNumberµÄÎÊÌ⣬jsonnsnumber

    2016-01-17 15:03

  • iOS¿ª·¢PostÇëÇó´íÎó£ºError Domain=NSCocoaErrorDomain Code=3840

    iOS¿ª·¢PostÇëÇó´íÎó£ºError Domain=NSCocoaErrorDomain Code=3840 "

    2015-11-23 19:03

  • ¶ÔJson½øÐд¦ÀíµÄGoogle Gson API½Ì³Ì

    ¶ÔJson½øÐд¦ÀíµÄGoogle Gson API½Ì³Ì

    2015-11-23 15:47

ÍøÓѵãÆÀ
ø