diff --git a/waynboot-generator/src/main/test/com/test/BufferedInputFile.java b/waynboot-generator/src/main/test/com/test/BufferedInputFile.java new file mode 100644 index 0000000..004bb25 --- /dev/null +++ b/waynboot-generator/src/main/test/com/test/BufferedInputFile.java @@ -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(); + } + } + +} diff --git a/waynboot-generator/src/main/test/com/test/FileRead.java b/waynboot-generator/src/main/test/com/test/FileRead.java new file mode 100644 index 0000000..df89d0a --- /dev/null +++ b/waynboot-generator/src/main/test/com/test/FileRead.java @@ -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(); + } + + } +} diff --git a/waynboot-generator/src/main/test/com/test/Test.java b/waynboot-generator/src/main/test/com/test/NIOTest.java similarity index 94% rename from waynboot-generator/src/main/test/com/test/Test.java rename to waynboot-generator/src/main/test/com/test/NIOTest.java index 0de4941..9a5415b 100644 --- a/waynboot-generator/src/main/test/com/test/Test.java +++ b/waynboot-generator/src/main/test/com/test/NIOTest.java @@ -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(); } } diff --git a/waynboot-generator/src/main/test/com/test/OSExecute.java b/waynboot-generator/src/main/test/com/test/OSExecute.java new file mode 100644 index 0000000..de8f7db --- /dev/null +++ b/waynboot-generator/src/main/test/com/test/OSExecute.java @@ -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"); + } +} diff --git a/waynboot-generator/src/main/test/com/test/TestEOF.java b/waynboot-generator/src/main/test/com/test/TestEOF.java new file mode 100644 index 0000000..d8b86e0 --- /dev/null +++ b/waynboot-generator/src/main/test/com/test/TestEOF.java @@ -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(); + } + } +} diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java index 5f245fa..40376dd 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java @@ -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); } }