- 博客(64)
- 资源 (2)
- 收藏
- 关注
原创 导入play框架项目时报错Error opening zip file or JAR manifest missing : D:\play-1.2.5/framework/play-1.2.5.jar
解决的方法:eclipse文件夹下找到 “项目名.launch”,中搜索“D:\play-1.2.5/framework/play-1.2.5.jar”。将搜索到的位置改为当前所配置环境中的“play-1.2.5.jar”的路径,就可以了....
2019-07-09 09:44:56
1404
原创 一个函数可以记录0~n之间出现"1"的次数(比如f(1) = 1,f(13) = 6 (1、10、11、12、13)),求出f(n)=n的最大值
public static void main(String[] args) { int n = 2; int result = 1; while((getOne(n)+result)!=n) { result = result +getOne(n); n++; } System.out.println(n);...
2019-03-12 14:18:57
399
原创 输入一串数字,打印出这串数字所有数字等长的不同排列,且没有重复
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); Choice(s,""); } static void Choice(String s,String p) { i...
2019-03-12 13:27:38
683
原创 给定一个无序数组,包含正数、负数和0,要求从中找出3个数的乘积,使得乘积最大
输入描述:首先输入n,代表数组内整数的个数再依次输入整数输入用例:613472 -7098 -9281 7789 7955 6101 5051 7778 3090 7423 -7151 5652 1595 -8094 677 -8324 8347 -2482 9313 -9338 -3157 8559 6945 3618 3087 121 -8468 3225 1356 6...
2019-03-10 13:08:42
3904
1
原创 给定区间[-2的31次方, 2的31次方]内的3个整数A、B和C,请判断A+B是否大于C。
public class test { public static void main(String[] args) { int T;//输入第1行给出正整数T,是测试用例的个数。 String a,b,c; Scanner sc=new Scanner(System.in); T = sc.nextInt(); String arr[][] = new Stri...
2019-03-07 21:11:16
1143
1
原创 客户端服务端网络编程---实现上传文件
客户端:ublic class Client { public static void main(String[] args) throws UnknownHostException, IOException { File file = getFile(); Socket socket = new Socket("127.0.0.1", 8888); BufferedRea...
2019-03-06 22:12:12
485
原创 客户端服务端网络编程---实现输入一段文本再倒序输出
服务端:public class Server { public static void main(String[] args) throws IOException { ServerSocket server = new ServerSocket(8888); System.out.println("Server is running"); while (true) { ...
2019-03-05 17:11:42
433
原创 UDP传输多线程
class Receive extends Thread { public void run() { try { DatagramSocket socket = new DatagramSocket(9999); DatagramPacket packet = new DatagramPacket(new byte[1024], 1024); while (true) {...
2019-03-02 14:35:44
1294
原创 UDP传输
public class send { public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); DatagramSocket socket = new DatagramSocket(); while...
2019-03-01 15:39:17
361
原创 简单工厂设计模式
class AnimalFactory{ public static Dog createDog() { return new Dog(); } public static Cat createCat() { return new Cat(); } public static Animal createAnimal(String name) { if("Dog".equ...
2019-02-28 15:45:59
172
原创 线程池的使用
class Out { private int i = 1; private ReentrantLock r = new ReentrantLock();//锁对象 private Condition c1 = r.newCondition();// private Condition c2 = r.newCondition(); private Condition c3 = r.n...
2019-02-28 14:41:30
114
原创 多线程之间的通信 唤醒指定线程
class Out { private int i = 1; private ReentrantLock r = new ReentrantLock();//锁对象 private Condition c1 = r.newCondition();// private Condition c2 = r.newCondition(); private Condition c3 = r.n...
2019-02-27 20:55:33
1851
原创 多个线程之间的通信
class Out { private int i = 1; public void out1() throws InterruptedException { synchronized (this) { while (i != 1) { this.wait(); } Thread.sleep(1000);//sleep一秒以便更好的观察效果 Syste...
2019-02-27 16:02:24
218
原创 两个线程之间的通信
class Out { private int i = 1; public void out1() throws InterruptedException { synchronized (this) {//给线程加锁 if (i %2 == 1) { this.wait();//当i余2等于一时,线程等待 } System.out.println("1号...
2019-02-26 19:04:10
2044
原创 Timer类计时器
class MyTimetask extends TimerTask{ public void run() { System.out.println("闹钟响了"); }}class hello { @SuppressWarnings("deprecation") public static void main(String[] args) throws IOExceptio...
2019-02-26 16:38:06
466
原创 懒汉式和饿汉式实现单例模式
class Single { private Single() {};//私有构造方法 private static Single s = new Single(); public static Single get() { if(s == null) { s = new Single(); } return s; }//懒汉式*/ /* public s...
2019-02-25 19:16:41
1558
原创 多线程模拟火车售票
class hello { public static void main(String[] args) throws IOException { Ticket t = new Ticket(); new Thread(t).start();// 模拟四个售票窗口同时售票 new Thread(t).start(); new Thread(t).start(); new ...
2019-02-24 20:39:53
698
原创 匿名内部类实现多线程
public static void main(String[] args) throws IOException { new Thread(){ public void run() { for(int i = 0;i < 100000;i++) { System.out.println("一"); } } }.start(); ...
2019-02-23 17:39:35
443
原创 简单多线程实现
public static void main(String[] args) throws IOException { MYThread mt = new MYThread(); MYRunnale mr = new MYRunnale(); mt.start(); mr.run(); }class MYThread extends Thread{ public voi...
2019-02-23 17:06:19
407
原创 约瑟夫环问题
已知i个人围坐在一张圆桌周围。从编号为1的人开始报数,数到3的那个人出列;他的下一个人又从1开始报数,数到3的那个人又出列;依此规律重复下去,直到圆桌周围的人全部出列。public static void main(String[] args) throws IOException { System.out.println(fun(10));//十个人数数 } public st...
2019-02-23 16:21:35
192
原创 计算100的阶乘末位0的个数
public static void main(String[] args) throws IOException { BigInteger Num = new BigInteger("1"); int i = 1,count = 0; for(;i<=100;i++) { BigInteger I = new BigInteger(i+"");//将int数i转换...
2019-02-23 15:21:17
658
1
原创 File类实现文件的分层打印
public static void main(String[] args) throws IOException { File dir = Dir(); Print(dir,0); }public static void Print(File dir, int a) {//定义一个整型参数a记录文件的层级 File[] files = dir.listFiles(); ...
2019-02-23 14:31:29
196
原创 利用File类和IO流将一个文件夹的所有内容拷贝到另一个文件夹下
class hello { public static void main(String[] args) throws IOException { File one = Dir(); File two = Dir(); if(one.equals(two)) { System.out.println("目标文件是源文件夹的子文件夹"); }else { Co...
2019-02-22 17:04:35
2458
原创 File类实现删除文件
class hello { public static void main(String[] args) throws IOException { File dir = Dir(); Delete(dir); } public static File Dir() {//获取文件夹路径方法 Scanner sc = new Scanner(System.in); Stri...
2019-02-22 16:17:02
5152
原创 File类实现计算文件夹的大小
public static void main(String[] args) throws IOException { File dir = Dir(); double d = Length(dir)/1024/1024; System.out.println("文件的大小为"+ d +"MB"); } public static File Dir() {//获取文件夹路...
2019-02-22 15:57:05
1353
原创 Properties的使用
class hello { public static void main(String[] args) throws IOException { Properties prop = new Properties(); prop.load(new FileInputStream("info.txt")); Enumeration<String> elemen...
2019-02-21 17:44:28
115
原创 IO随机访问流在制定位置插入字符
class hello { public static void main(String[] args) throws IOException { RandomAccessFile raf = new RandomAccessFile("yyy.txt", "rw"); raf.seek(10); raf.write(98); raf.close(); }运行结果:...
2019-02-21 16:51:34
258
原创 IO对象操作流序列化及反序列化多个对象
主函数: public static void main(String[] args) throws IOException, ClassNotFoundException { Animal cat = new Animal("cat", 4); Animal dog = new Animal("dog", 4); Animal snake = new Animal("sna...
2019-02-21 14:45:54
619
原创 IO内存流读取文本数据并转换为字符流打印
class hello { public static void main(String[] args) throws IOException { FileInputStream input = new FileInputStream("xxx.txt"); ByteArrayOutputStream boi = new ByteArrayOutputStream(); byte...
2019-02-12 16:16:21
492
原创 利用IO序列流和枚举将多个文本文件整合到一个
class hello { public static void main(String[] args) throws IOException { FileInputStream input1 = new FileInputStream("input1.txt"); FileInputStream input2 = new FileInputStream("input2.txt");...
2019-02-12 14:51:01
245
原创 利用IO序列流SequenceInputStream将两个文本文件整合到一个中
class hello { public static void main(String[] args) throws IOException { FileInputStream input1 = new FileInputStream("input1.txt"); FileInputStream input2 = new FileInputStream("input2.txt")...
2019-02-12 14:03:56
363
原创 利用File类递归,实现输入文件路径,检索出指定文件类型的文件
class hello { public static void main(String[] args) { File dir = Dir(); PrintFile(dir); } public static File Dir() { Scanner sc = new Scanner(System.in); System.out.println("输入文件夹路径:")...
2019-02-11 15:16:30
358
原创 利用Treemap和BufferedReader、BufferedWriter记录文本中每个字符出现的次数
class hello { public static void main(String[] args) throws IOException { BufferedReader isp = new BufferedReader(new FileReader("xxx.txt")); BufferedWriter osw = new BufferedWriter(new FileWr...
2019-01-25 17:46:10
187
原创 利用OutputStreamWriter用特定的编码写字符
class hello { public static void main(String[] args) throws IOException { BufferedReader isp = new BufferedReader(new FileReader("xxx.txt")); //OutputStreamWriter osw = new OutputStreamWriter...
2019-01-25 16:55:24
11057
原创 利用bufferstream和arraylist实现将一段文本倒序输出
class hello { public static void main(String[] args) throws IOException { BufferedReader fr = new BufferedReader(new FileReader("xxx.txt")); BufferedWriter fw = new BufferedWriter(new FileWri...
2019-01-25 13:16:14
515
1
原创 IO流--利用BufferedOutputStream将录入的数据写到文件中,直到输入“exit”后退出
class hello { public static void main(String[] args) throws IOException { String s; Scanner sc = new Scanner(System.in); BufferedOutputStream output = new BufferedOutputStream(new FileOutput...
2019-01-10 16:07:44
1314
原创 IO流--利用bufferedstream在控制台中输入文件路径,并将文件复制到桌面
class hello { public static void main(String[] args) throws IOException { BufferedInputStream input = new BufferedInputStream(new FileInputStream(InputPath())); BufferedOutputStream outpu...
2019-01-10 15:29:19
496
原创 利用BufferStream来进行图片加密与解密
加密类:public static void JiaMi() { int a; try { BufferedInputStream input = new BufferedInputStream( new FileInputStream("C:\\Users\\Lee\\Desktop\\001.jpg")); BufferedOutputStream outp...
2019-01-09 20:25:10
431
原创 利用FileInputStream中 available方法实现复制文件的操作
class hello { public static void main(String[] args) throws ParseException, IOException { FileInputStream input = new FileInputStream("C:\\Users\\Lee\\Desktop\\001.jpg"); FileOutputStream out...
2019-01-09 14:22:01
603
1
原创 File类在指定目录下寻找特定格式的文件
class hello { public static void main(String[] args) throws ParseException { File dir = new File("C:\\Users\\Lee\\Pictures\\Saved Pictures"); String arr[] = dir.list(); for (String string : ar...
2019-01-07 19:14:25
554
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人