feat(代码生成模块): 添加测试代码

master
hequan_waynaqua 4 years ago
parent c87236047c
commit 8b2412f428

@ -0,0 +1,17 @@
package com.test;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.stream.Collectors;
public class BufferedInputFile {
public static void main(String[] args) {
try (BufferedReader reader = new BufferedReader(new FileReader("E:/data.txt"))) {
System.out.println(reader.lines().collect(Collectors.joining("\n")));
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,23 @@
package com.test;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class FileRead {
public static void main(String[] args) {
try (FileReader fileReader = new FileReader("E:/data.txt")) {
char arr[] = new char[1024];
int len;
while ((len = fileReader.read(arr)) != -1) {
System.out.println(new String(arr,0 ,len));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -6,7 +6,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class Test {
public class NIOTest {
private static String name = "E:/data.txt";
private static final int BSIZE = 1024;
@ -27,6 +27,7 @@ public class Test {
buff.flip();
while (buff.hasRemaining())
System.out.write(buff.get());
System.out.println();
System.out.flush();
}
}

@ -0,0 +1,38 @@
package com.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class OSExecute {
public static void command(String command) throws Exception {
boolean err = false;
try {
Process process = new ProcessBuilder(
command.split(" ")).start();
try (
BufferedReader results = new BufferedReader(
new InputStreamReader(
process.getInputStream(), "gbK"));
BufferedReader errors = new BufferedReader(
new InputStreamReader(
process.getErrorStream()))
) {
results.lines()
.forEach(System.out::println);
err = errors.lines()
.peek(System.err::println)
.count() > 0;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
if (err)
throw new Exception(
"Errors executing " + command);
}
public static void main(String[] args) throws Exception {
command("java -version");
}
}

@ -0,0 +1,20 @@
package com.test;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TestEOF {
public static void main(String[] args) {
try (DataInputStream in = new DataInputStream(new FileInputStream("E:/data.txt"))) {
while (in.available() != 0) {
System.out.write(in.readByte());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -4,6 +4,7 @@ import com.wayn.common.util.R;
import com.wayn.mobile.api.service.IGoodsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -15,7 +16,7 @@ public class GoodsController {
private IGoodsDetailService iGoodsDetailService;
@GetMapping("detail/{goodsId}")
public R detail(Long goodsId) {
public R detail(@PathVariable Long goodsId) {
return iGoodsDetailService.getGoodsDetailData(goodsId);
}
}

Loading…
Cancel
Save