1. import java.awt.Container;
  2. import java.awt.GridBagConstraints;
  3. import java.awt.GridBagLayout;
  4. import java.awt.Insets;
  5. import java.io.File;
  6. import java.io.InputStream;
  7. import java.io.PrintStream;
  8. import java.util.Vector;
  9.  
  10. import javax.swing.JLabel;
  11. import javax.swing.JOptionPane;
  12. import javax.swing.JPanel;
  13. import javax.swing.JPasswordField;
  14. import javax.swing.JTextField;
  15. import javax.swing.ProgressMonitor;
  16.  
  17. import com.jcraft.jsch.Channel;
  18. import com.jcraft.jsch.ChannelSftp;
  19. import com.jcraft.jsch.ChannelSftp.LsEntry;
  20. import com.jcraft.jsch.JSch;
  21. import com.jcraft.jsch.Session;
  22. import com.jcraft.jsch.SftpATTRS;
  23. import com.jcraft.jsch.SftpProgressMonitor;
  24. import com.jcraft.jsch.SftpStatVFS;
  25. import com.jcraft.jsch.UIKeyboardInteractive;
  26. import com.jcraft.jsch.UserInfo;
  27.  
  28. public class Sftp {
  29. public static void main(String[] args) {
  30. try {
  31. JSch jsch = new JSch();
  32.  
  33. String host = null;
  34. if (args.length > 0) {
  35. host = args[0];
  36. } else {
  37. host = JOptionPane.showInputDialog("Enter username@hostname",
  38. System.getProperty("user.name") + "@localhost");
  39. }
  40.  
  41. String user = host.substring(0, host.indexOf('@'));
  42. host = host.substring(host.indexOf('@') + 1);
  43. int port = 22;
  44.  
  45. Session session = jsch.getSession(user, host, port);
  46.  
  47. UserInfo userinfo = new MyUserInfo();
  48. session.setUserInfo(userinfo);
  49. session.connect();
  50.  
  51. Channel channel = session.openChannel("sftp");
  52. channel.connect();
  53. ChannelSftp channelSftp = (ChannelSftp)channel;
  54.  
  55. InputStream in = System.in;
  56. PrintStream out = System.out;
  57.  
  58. Vector cmds = new Vector();
  59. byte[] buf = new byte[1024];
  60. int i;
  61. String str;
  62. int level = 0;
  63.  
  64. while (true) {
  65. out.print("sftp> ");
  66. cmds.removeAllElements();
  67.  
  68. i = in.read(buf, 0, 1024);
  69. if (i <= 0) {
  70. break;
  71. }
  72. i--;
  73. if (i > 0 && buf[i-1] == 0x0d) {
  74. i--;
  75. }
  76.  
  77. int s = 0;
  78. for (int ii = 0; ii < i; ii++) {
  79. if (' ' == buf[ii]) {
  80. if (ii - s > 0) {
  81. cmds.addElement(new String(buf, s, ii - s));
  82. }
  83.  
  84. while (ii < i) {
  85. if (' ' != buf[ii]) {
  86. break;
  87. }
  88. ii++;
  89. }
  90. s = ii;
  91. }
  92. }
  93.  
  94. if (s < i) {
  95. cmds.addElement(new String(buf, s, i - s));
  96. }
  97.  
  98. if (0 == cmds.size()) {
  99. continue;
  100. }
  101.  
  102. String cmd = (String) cmds.elementAt(0);
  103. if (cmd.equals("quit")) {
  104. channelSftp.quit();
  105. break;
  106. }
  107.  
  108. if (cmd.equals("exit")) {
  109. channelSftp.exit();
  110. break;
  111. }
  112.  
  113. if (cmd.equals("rekey")) {
  114. session.rekey();
  115. continue;
  116. }
  117.  
  118. if (cmd.equals("compression")) {
  119. if (cmds.size() < 2) {
  120. out.println("compression level: " + level);
  121. continue;
  122. }
  123.  
  124. try {
  125. level = Integer.parseInt((String)cmds.elementAt(1));
  126. if (0 == level) {
  127. session.setConfig("compression.s2c", "none");
  128. session.setConfig("compression.c2s", "none");
  129. } else {
  130. session.setConfig("compression.s2c", "zlib@openssh.com,zlib,none");
  131. session.setConfig("compression.c2s", "zlib@openssh.com,zlib,none");
  132. }
  133. } catch (Exception e) {}
  134. session.rekey();
  135. continue;
  136. }
  137.  
  138. if (cmd.equals("cd") || cmd.equals("lcd")) {
  139. if (cmds.size() < 2) {
  140. continue;
  141. }
  142. String path = (String)cmds.elementAt(1);
  143.  
  144. try {
  145. if (cmd.equals("cd")) {
  146. channelSftp.cd(path);
  147. } else {
  148. channelSftp.lcd(path);
  149. }
  150. } catch (Exception e) {
  151. System.out.println(e.toString());
  152. }
  153. continue;
  154. }
  155.  
  156. if (cmd.equals("rm") || cmd.equals("rmdir") || cmd.equals("mkdir")) {
  157. if (cmds.size() < 2) {
  158. continue;
  159. }
  160.  
  161. String path = (String)cmds.elementAt(1);
  162. try {
  163. if (cmd.equals("rm")) {
  164. channelSftp.rm(path);
  165. } else if (cmd.equals("rmdir")) {
  166. channelSftp.rmdir(path);
  167. } else {
  168. channelSftp.mkdir(path);
  169. }
  170. } catch (Exception e) {
  171. System.out.println(e.toString());
  172. }
  173. continue;
  174. }
  175.  
  176. if (cmd.equals("chgrp") || cmd.equals("chown") || cmd.equals("chmod")) {
  177. if (3 != cmds.size()) {
  178. continue;
  179. }
  180.  
  181. String path = (String)cmds.elementAt(2);
  182. int foo = 0;
  183. if (cmd.equals("chmod")) {
  184. byte[] bar = ((String)cmds.elementAt(1)).getBytes();
  185. int k;
  186. for (int j = 0; j < bar.length; j++) {
  187. k = bar[j];
  188. if (k < '0' || k > '7') {
  189. foo = -1;
  190. break;
  191. }
  192. foo <<= 3;
  193. foo |= (k - '0');
  194. }
  195. if (-1 == foo) {
  196. continue;
  197. }
  198. } else {
  199. try {
  200. foo = Integer.parseInt((String)cmds.elementAt(1));
  201. } catch (Exception e) {
  202. continue;
  203. }
  204. }
  205.  
  206. try {
  207. if (cmd.equals("chgrp")) {
  208. channelSftp.chgrp(foo, path);
  209. } else if (cmd.equals("chown")) {
  210. channelSftp.chown(foo, path);
  211. } else if (cmd.equals("chmod")) {
  212. channelSftp.chmod(foo, path);
  213. }
  214. } catch (Exception e) {
  215. System.out.println(e.toString());
  216. }
  217. continue;
  218. }
  219.  
  220. if (cmd.equals("pwd") || cmd.equals("lpwd")) {
  221. str = (cmd.equals("pwd") ? "Remote" : "Local");
  222. str += " working directory: ";
  223. if (cmd.equals("pwd")) {
  224. str += channelSftp.pwd();
  225. } else {
  226. str += channelSftp.lpwd();
  227. }
  228. out.println(str);
  229. continue;
  230. }
  231.  
  232. if (cmd.equals("ls") || cmd.equals("dir")) {
  233. String path = ".";
  234. if (2 == cmds.size()) {
  235. path = (String)cmds.elementAt(1);
  236. }
  237.  
  238. try {
  239. Vector vv = channelSftp.ls(path);
  240. if (null != vv) {
  241. for (int ii = 0; ii < vv.size(); ii++) {
  242. Object object = vv.elementAt(ii);
  243. if (object instanceof LsEntry) {
  244. out.println(((LsEntry)object).getLongname());
  245. }
  246. }
  247. }
  248. } catch (Exception e) {
  249. System.out.println(e.toString());
  250. }
  251. continue;
  252. }
  253.  
  254. if (cmds.equals("lls") || cmds.equals("ldir")) {
  255. String path = ".";
  256. if (2 == cmds.size()) {
  257. path = (String)cmds.elementAt(1);
  258. }
  259.  
  260. try {
  261. File file = new File(path);
  262. if (!file.exists()) {
  263. out.println(path + ": No such file or directory");
  264. continue;
  265. }
  266.  
  267. if (file.isDirectory()) {
  268. String[] list = file.list();
  269. for (int ii = 0; ii < list.length; ii++) {
  270. out.println(list[ii]);
  271. }
  272. continue;
  273. }
  274. out.println(path);
  275. } catch (Exception e) {
  276. // TODO: handle exception
  277. out.println(path);
  278. }
  279. continue;
  280. }
  281.  
  282. if (cmd.equals("get") ||
  283. cmd.equals("get-resume") ||
  284. cmd.equals("get-append") ||
  285. cmd.equals("put") ||
  286. cmd.equals("put-resume") ||
  287. cmd.equals("put-append")) {
  288.  
  289. if (2 != cmds.size() && 3 != cmds.size()) {
  290. continue;
  291. }
  292.  
  293. String p1 = (String)cmds.elementAt(1);
  294. String p2 = ".";
  295.  
  296. if (3 == cmds.size()) {
  297. p2 = (String)cmds.elementAt(2);
  298. }
  299.  
  300. try {
  301. SftpProgressMonitor monitor = new MyProgressMonitor();
  302. if (cmd.startsWith("get")) {
  303. int mode = ChannelSftp.OVERWRITE;
  304. if (cmd.equals("get-resume")) {
  305. mode = ChannelSftp.RESUME;
  306. } else if (cmd.equals("get-append")) {
  307. mode = ChannelSftp.APPEND;
  308. }
  309. channelSftp.get(p1, p2, monitor, mode);
  310. } else {
  311. int mode = ChannelSftp.OVERWRITE;
  312. if (cmd.equals("put-resume")) {
  313. mode = ChannelSftp.RESUME;
  314. } else if (cmd.equals("put-append")) {
  315. mode = ChannelSftp.APPEND;
  316. }
  317. channelSftp.put(p1, p2, monitor, mode);
  318. }
  319. } catch (Exception e) {
  320. // TODO: handle exception
  321. System.out.println(e.toString());
  322. }
  323. continue;
  324. }
  325.  
  326. if (cmd.equals("ln") || cmd.equals("symlink") || cmd.equals("rename") || cmd.equals("hardlink")) {
  327. if (3 != cmds.size()) {
  328. continue;
  329. }
  330. String p1 = (String)cmds.elementAt(1);
  331. String p2 = (String)cmds.elementAt(2);
  332.  
  333. try {
  334. if (cmd.equals("hardlink")) {
  335. channelSftp.hardlink(p1, p2);
  336. } else if (cmd.equals("rename")) {
  337. channelSftp.rename(p1, p2);
  338. } else {
  339. channelSftp.symlink(p1, p2);
  340. }
  341. } catch (Exception e) {
  342. // TODO: handle exception
  343. System.out.println(e.toString());
  344. }
  345. continue;
  346. }
  347.  
  348. if (cmd.equals("df")) {
  349. if (cmds.size() > 2) {
  350. continue;
  351. }
  352. String p1 = 1 == cmds.size() ? "." : (String)cmds.elementAt(1);
  353. SftpStatVFS stat = channelSftp.statVFS(p1);
  354.  
  355. long size = stat.getSize();
  356. long used = stat.getUsed();
  357. long avail = stat.getAvailForNonRoot();
  358. long root_avail = stat.getAvail();
  359. long capacity = stat.getCapacity();
  360.  
  361. System.out.println("Size: " + size);
  362. System.out.println("Used: " + used);
  363. System.out.println("Avail: " + avail);
  364. System.out.println("(root): " + root_avail);
  365. System.out.println("%Capacity: " + capacity);
  366.  
  367. continue;
  368. }
  369.  
  370. if (cmd.equals("stat") || cmd.equals("lstat")) {
  371. if (2 != cmds.size()) {
  372. continue;
  373. }
  374.  
  375. String p1 = (String)cmds.elementAt(1);
  376. SftpATTRS attrs = null;
  377.  
  378. try {
  379. if (cmd.equals("stat")) {
  380. attrs = channelSftp.stat(p1);
  381. } else {
  382. attrs = channelSftp.lstat(p1);
  383. }
  384. } catch (Exception e) {
  385. // TODO: handle exception
  386. System.out.println(e.toString());
  387. }
  388.  
  389. if (null != attrs) {
  390. out.println(attrs);
  391. }
  392.  
  393. continue;
  394. }
  395.  
  396. if (cmd.equals("readlink")) {
  397. if (2 != cmds.size()) {
  398. continue;
  399. }
  400.  
  401. String p1 = (String)cmds.elementAt(1);
  402. String filename = null;
  403.  
  404. try {
  405. filename = channelSftp.readlink(p1);
  406. out.println(filename);
  407. } catch (Exception e) {
  408. // TODO: handle exception
  409. System.out.println(e.toString());
  410. }
  411.  
  412. continue;
  413. }
  414.  
  415. if (cmd.equals("realpath")) {
  416. if (2 != cmds.size()) {
  417. continue;
  418. }
  419.  
  420. String p1 = (String)cmds.elementAt(1);
  421. String filename = null;
  422.  
  423. try {
  424. filename = channelSftp.realpath(p1);
  425. out.println(filename);
  426. } catch (Exception e) {
  427. // TODO: handle exception
  428. System.out.println(e.toString());
  429. }
  430.  
  431. continue;
  432. }
  433.  
  434. if (cmd.equals("version")) {
  435. out.println("SFTP protocol version " + channelSftp.version());
  436. continue;
  437. }
  438.  
  439. if (cmd.equals("help") || cmd.equals("?")) {
  440. out.println(help);
  441. continue;
  442. }
  443.  
  444. out.println("unimplemented command: " + cmd);
  445. }
  446. session.disconnect();
  447. } catch (Exception e) {
  448. // TODO: handle exception
  449. System.out.println(e);
  450. }
  451. System.exit(0);
  452. }
  453.  
  454. public static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
  455. String passwd;
  456. JTextField passwordField = (JTextField)new JPasswordField(20);
  457. final GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1,
  458. GridBagConstraints.NORTHWEST,
  459. GridBagConstraints.NONE,
  460. new Insets(0, 0, 0, 0), 0, 0);
  461. Container panel;
  462.  
  463. @Override
  464. public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt,
  465. boolean[] echo) {
  466. panel = new JPanel();
  467. panel.setLayout(new GridBagLayout());
  468.  
  469. gbc.weightx = 1.0;
  470. gbc.gridwidth = GridBagConstraints.REMAINDER;
  471. gbc.gridx = 0;
  472. panel.add(new JLabel(instruction), gbc);
  473. gbc.gridy++;
  474.  
  475. gbc.gridwidth = GridBagConstraints.RELATIVE;
  476.  
  477. JTextField[] texts = new JTextField[prompt.length];
  478. for (int i = 0; i < prompt.length; i++) {
  479. gbc.fill = GridBagConstraints.NONE;
  480. gbc.gridx = 0;
  481. gbc.weightx = 1;
  482. panel.add(new JLabel(prompt[i]), gbc);
  483.  
  484. gbc.gridx = 1;
  485. gbc.fill = GridBagConstraints.HORIZONTAL;
  486. gbc.weighty = 1;
  487. if (echo[i]) {
  488. texts[i] = new JTextField(20);
  489. } else {
  490. texts[i] = new JPasswordField(20);
  491. }
  492. panel.add(texts[i], gbc);
  493. gbc.gridy++;
  494. }
  495.  
  496. if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, panel,
  497. destination + ": " + name,
  498. JOptionPane.OK_CANCEL_OPTION,
  499. JOptionPane.QUESTION_MESSAGE)) {
  500. String[] response = new String[prompt.length];
  501. for (int i = 0; i < prompt.length; i++) {
  502. response[i] = texts[i].getText();
  503. }
  504.  
  505. return response;
  506. } else {
  507. return null; // cancel
  508. }
  509. }
  510.  
  511. @Override
  512. public String getPassphrase() {
  513. // TODO Auto-generated method stub
  514. return null;
  515. }
  516.  
  517. @Override
  518. public String getPassword() {
  519. // TODO Auto-generated method stub
  520. return passwd;
  521. }
  522.  
  523. @Override
  524. public boolean promptPassphrase(String message) {
  525. // TODO Auto-generated method stub
  526. return true;
  527. }
  528.  
  529. @Override
  530. public boolean promptPassword(String message) {
  531. Object[] ob = { passwordField };
  532. int result = JOptionPane.showConfirmDialog(null, ob, message, JOptionPane.OK_CANCEL_OPTION);
  533.  
  534. if (JOptionPane.OK_OPTION == result) {
  535. passwd = passwordField.getText();
  536. return true;
  537. } else {
  538. return false;
  539. }
  540. }
  541.  
  542. @Override
  543. public boolean promptYesNo(String message) {
  544. Object[] options = { "yes", "no" };
  545. int foo = JOptionPane.showOptionDialog(null, message, "warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
  546.  
  547. return 0 == foo;
  548. }
  549.  
  550. @Override
  551. public void showMessage(String message) {
  552. // TODO Auto-generated method stub
  553. JOptionPane.showMessageDialog(null, message);
  554. }
  555.  
  556. }
  557.  
  558. public static class MyProgressMonitor implements SftpProgressMonitor {
  559. ProgressMonitor monitor;
  560. long count = 0;
  561. long max = 0;
  562. private long percent = -1;
  563.  
  564. @Override
  565. public boolean count(long count) {
  566. this.count += count;
  567.  
  568. if (percent >= this.count * 100 / max) {
  569. return true;
  570. }
  571.  
  572. percent = this.count * 100 / max;
  573.  
  574. monitor.setNote("Completed " + this.count + "(" + percent + "%) out of " + max + ".");
  575. monitor.setProgress((int)this.count);
  576.  
  577. return !(monitor.isCanceled());
  578. }
  579.  
  580. @Override
  581. public void end() {
  582. monitor.close();
  583. }
  584.  
  585. @Override
  586. public void init(int op, String src, String dest, long max) {
  587. this.max = max;
  588. monitor = new ProgressMonitor(null,
  589. ((SftpProgressMonitor.PUT == op) ? "put" : "get" + ": " + src),
  590. "", 0, (int)max);
  591. count = 0;
  592. percent = -1;
  593. monitor.setProgress((int)this.count);
  594. monitor.setMillisToDecideToPopup(1000);
  595. }
  596. }
  597.  
  598. private static String help = " Available commands:\n"+
  599. " * means unimplemented command.\n"+
  600. "cd path Change remote directory to 'path'\n"+
  601. "lcd path Change local directory to 'path'\n"+
  602. "chgrp grp path Change group of file 'path' to 'grp'\n"+
  603. "chmod mode path Change permissions of file 'path' to 'mode'\n"+
  604. "chown own path Change owner of file 'path' to 'own'\n"+
  605. "df [path] Display statistics for current directory or\n"+
  606. " filesystem containing 'path'\n"+
  607. "help Display this help text\n"+
  608. "get remote-path [local-path] Download file\n"+
  609. "get-resume remote-path [local-path] Resume to download file.\n"+
  610. "get-append remote-path [local-path] Append remote file to local file\n"+
  611. "hardlink oldpath newpath Hardlink remote file\n"+
  612. "*lls [ls-options [path]] Display local directory listing\n"+
  613. "ln oldpath newpath Symlink remote file\n"+
  614. "*lmkdir path Create local directory\n"+
  615. "lpwd Print local working directory\n"+
  616. "ls [path] Display remote directory listing\n"+
  617. "*lumask umask Set local umask to 'umask'\n"+
  618. "mkdir path Create remote directory\n"+
  619. "put local-path [remote-path] Upload file\n"+
  620. "put-resume local-path [remote-path] Resume to upload file\n"+
  621. "put-append local-path [remote-path] Append local file to remote file.\n"+
  622. "pwd Display remote working directory\n"+
  623. "stat path Display info about path\n"+
  624. "exit Quit sftp\n"+
  625. "quit Quit sftp\n"+
  626. "rename oldpath newpath Rename remote file\n"+
  627. "rmdir path Remove remote directory\n"+
  628. "rm path Delete remote file\n"+
  629. "symlink oldpath newpath Symlink remote file\n"+
  630. "readlink path Check the target of a symbolic link\n"+
  631. "realpath path Canonicalize the path\n"+
  632. "rekey Key re-exchanging\n"+
  633. "compression level Packet compression will be enabled\n"+
  634. "version Show SFTP version\n"+
  635. "? Synonym for help";
  636. }

jcraft--SFTP demo的更多相关文章

  1. SFTP数据迁移

    背景 服务器部署到aliyun上,之前sftp数据又是在系统盘上,由于现在数据量越来越大,导致系统盘无法满足现有要求,所以需要对sftp相关数据进行迁移至数据盘. 方案 方案一:原数据复制到新磁盘中, ...

  2. xftp的使用教程

    使用xftp来上传,下载文件到linux主机 首先,我们要下载一个xftp,因为官网是英文的,还需要邮件激活,在这里我把程序下载好 此时已经安装完成,点击finish,打开软件登录SSH账号,这里以默 ...

  3. 如何使用jcraft 模拟SFTP登陆

    大家如果熟悉Linux系统话,对ssh,sftp,scp等命令非常熟悉.ssh是一个安全协议,用来在不同系统或者服务器之间进行安全连接.ssh 在连接和传送的过程中会加密所有的数据. 而今天我要介绍的 ...

  4. java实操之使用jcraft进行sftp上传下载文件

    sftp作为临时的文件存储位置,在某些场合还是有其应景的,比如对账文件存放.需要提供一个上传的工具类.实现方法参考下: pom.xml中引入类库: <dependency> <gro ...

  5. 并发下sftp连接报错——com.jcraft.jsch.JSchException: connection is closed by foreign host

    当对单接口极限测试时,随着并发量上升,接口稳定性出现不稳定的情况,排查后台日志,发现报错在该接口调用sftp上传时出现问题(确切的是在初始化连接时失败) 原因:系统SSH终端连接数配置过小,查看虚拟机 ...

  6. 【SFTP】使用Jsch实现Sftp文件下载-支持断点续传和进程监控

    参考上篇文章: <[SFTP]使用Jsch实现Sftp文件下载-支持断点续传和进程监控>:http://www.cnblogs.com/ssslinppp/p/6248763.html  ...

  7. 【SFTP】使用Jsch实现Sftp文件上传-支持断点续传和进程监控

    JSch是Java Secure Channel的缩写.JSch是一个SSH2的纯Java实现.它允许你连接到一个SSH服务器,并且可以使用端口转发,X11转发,文件传输等,当然你也可以集成它的功能到 ...

  8. JAVA代码时间SFTP文件的下载

    参考文章:http://blog.csdn.net/smallerpig/article/details/50976191 SFTP文件的下载与FTP文件的下载差别较大,需要下载jsch-0.1.54 ...

  9. 【转】JSch - Java实现的SFTP(文件下载详解篇)

    上一篇讲述了使用JSch实现文件上传的功能,这一篇主要讲述一下JSch实现文件下载的功能.并介绍一些SFTP的辅助方法,如cd,ls等.   同样,JSch的文件下载也支持三种传输模式:OVERWRI ...

  10. 【转】JSch - Java实现的SFTP(文件上传详解篇)

    JSch是Java Secure Channel的缩写.JSch是一个SSH2的纯Java实现.它允许你连接到一个SSH服务器,并且可以使用端口转发,X11转发,文件传输等,当然你也可以集成它的功能到 ...

随机推荐

  1. idea 占用内存优化调整

      idea 占用内存优化调整 https://www.cnblogs.com/metoy/p/5967696.html   https://blog.csdn.net/zdxxinlang/arti ...

  2. Java集合中的细节问题

    1)集合不保存基本数据类型,而是会把基本数据类型装箱后保存. 2)Empty和null的区别:null是不存在,Empty已经初始化了,只不过里面是空的. 3)判断集合有效性: 先判断空,再判断emp ...

  3. 设计模式之第9章-原型模式(Java实现)

    设计模式之第9章-原型模式(Java实现) “快到春节了,终于快放假了,天天上班好累的说.”“确实啊,最近加班比较严重,项目快到交付了啊.”“话说一到过节,就收到铺天盖地的短信轰炸,你说发短信就发吧, ...

  4. IOS开发学习笔记029-反选、全选、删除按钮的实现

    还是在上一个程序的基础上进行修改 1.反选按钮 2.全选按钮 3.删除按钮 4.其他代码优化 1.反选按钮 反选的过程就是将_deleteShops数组中得数据清空,然后将Shops中数组添加到_de ...

  5. 了解JavaScript核心精髓(二)

    1.字符串操作 //声明字符串 var str = "abcd"; var str = new String("abcd") //截取字符串 console.l ...

  6. Cygwin访问盘符、使用别名、彩色显示、使用adb命令

    Cygwin是一个在Windows平台上运行的类UNIX模拟环境.安装过程我就不重复造轮子了,百度一下即可.其中安装的时候需要装哪些包,要看你用到哪些.比如我就是只用adb shell,所以全部默认安 ...

  7. 实战项目——获取图片中的GPS位置信息和拍摄时间

    今天突然看到有人写过获取图片中位置信息的程序.我觉得很有趣,也就自己实践了一下,研究了一下 话不多说,先上代码 #!/usr/bin/env python3 # -*- coding: utf-8 - ...

  8. SEO相关

    前端需要注意哪些SEO 合理的title.description.keywords: -- 搜索对着三项的权重逐个减小,title值强调重点即可,重要关键词出现不要超过2次,而且要靠前,不同页面tit ...

  9. Log4j官方文档翻译(三、配置)

    之前的章节介绍了log4j的核心组件,本章将会通过配置文件介绍一下核心组建的配置. 主要在配置文件中配置log4j的日志级别,定义appender.layout等. log4j.properties是 ...

  10. 论文笔记:《OverFeat: Integrated Recognition, Localization and Detection using Convolutional Networks DeepLearning 》

    一.Abstract综述 训练出一个CNN可以同时实现分类,定位和检测..,三个任务共用同一个CNN网络,只是在pool5之后有所不同 二.分类 这里CNN的结构是对ALEXNET做了一些改进,具体的 ...