Java 基础之IO 和NIO 补完
createDirectory(path); } catch(FileAlreadyExistsException e){ // the directory already exists. } catch (IOException e) { //something else went wrong e.printStackTrace(); } 3. Files.copy() Path sourcePath destinationPath); } catch(FileAlreadyExistsException e) { //destination file already exists } catch (IOException e) { //something else went wrong e.printStackTrace(); } 4. Overwriting Existing Files REPLACE_EXISTING); } catch(FileAlreadyExistsException e) { //destination file already exists } catch (IOException e) { //something else went wrong e.printStackTrace(); } 5. Files.move() ● java.io.File0 码力 | 9 页 | 218.38 KB | 1 年前3MYBATIS Quick Guide
in the Student table. Create and save mybatisInsert.java file as shown below − import java.io.IOException; import java.io.Reader; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session SqlSessionFactoryBuilder; public class mybatisInsert { public static void main(String args[]) throws IOException{ Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml"); SqlSessionFactory the Student table. Create and save mybatisRead_ALL.java file as shown below − import java.io.IOException; import java.io.Reader; import java.util.List; import org.apache.ibatis.io.Resources; import0 码力 | 34 页 | 301.72 KB | 1 年前3Java 应用与开发 - 异常处理
Java 异常处理机制 常见异常 O IOException ▶ 从一个不存在的文件中读取数据 ▶ 越过文件结尾继续读取 ▶ 连接一个不存在的 URL IOException 示例 1 课程配套代码 ± sample.exception.IOExceptionSample.java 1上述代码无法编译:只要是有可能出现 IOException 的 Java 代码,在编 译时就会出错,而不会等到运行时才发生。 常用,在没有找到适合的异常处理代码时,系统也 会自动调用该方法输出错误信息。 大纲 异常的概念及分类 Java 异常处理机制 捕获和处理 IOException O 一些知识点 ▶ 异常类型的多态性 FileNotFoundException 是 IOException 的子类,基于多态性机制,后一个 catch 语句也可以处理 FileNotFoundException,因此前一个 catch 语句块可以取 运行时异常 ▶ 过度处理 课程配套代码 ± sample.exception.IOExceptionSample.java 大纲 异常的概念及分类 Java 异常处理机制 捕获和处理 IOException O 一些知识点 ▶ 异常类型的多态性 ▶ 运行时异常 对于只可能产生 RuntimeException 的代码可以 不使用 try-catch 语句进行处理,如果对于这些相对安全的 代码仍然采用了0 码力 | 33 页 | 626.40 KB | 1 年前3《Java 应用与开发》课程讲义 - 王晓东
viii 12.2.3 操纵异常对象 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 12.2.4 捕获和处理 IOException . . . . . . . . . . . . . . . . . . . . . . . . 158 12.2.5 声明抛出异常 . . . . . . . . . . . . . . 2. JAVA 流程控制 � 2 � 2 public class MyClass { 3 public static void main(String[] args) throws IOException { 4 int num1, num2; 5 String str1, str2; 6 InputStreamReader in; 7 in = new InputStreamReader(System 读取控制台输入的传统方法 1 import java.io.InputStreamReader; 2 import java.io.BufferedReader; 3 import java.io.IOException; 5 public class TestStandardInput { . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 码力 | 330 页 | 6.54 MB | 1 年前3跟我学Shiro - 张开涛
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String error = null; String username = req.getParameter("username"); ServletException, IOException { doPost(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String0 码力 | 219 页 | 4.16 MB | 10 月前3Spring Boot 2.7.2 Reference Documentation
serializers/deserializers as inner classes, as shown in the following example: 127 Java import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { ObjectCodec codec = jsonParser.getCodec(); JsonNode tree = codec.readTree(jsonParser);0 码力 | 865 页 | 15.45 MB | 1 年前3Spring Boot 2.7.5 Reference Documentation
serializers/deserializers as inner classes, as shown in the following example: 127 Java import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { ObjectCodec codec = jsonParser.getCodec(); JsonNode tree = codec.readTree(jsonParser);0 码力 | 866 页 | 15.50 MB | 1 年前3Spring Boot 2.7.0-RC1 Reference Documentation
serializers/deserializers as inner classes, as shown in the following example: 128 Java import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { ObjectCodec codec = jsonParser.getCodec(); JsonNode tree = codec.readTree(jsonParser);0 码力 | 866 页 | 15.49 MB | 1 年前3Spring Boot 2.7.0-M2 Reference Documentation
serializers/deserializers as inner classes, as shown in the following example: 228 Java import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { jgen.writeStringField("name", value.getName()); jgen.writeNumberField("age" public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { ObjectCodec codec = jsonParser.getCodec(); JsonNode tree = codec.readTree(jsonParser);0 码力 | 851 页 | 15.24 MB | 1 年前3Spring Boot 2.7.3 Reference Documentation
serializers/deserializers as inner classes, as shown in the following example: 127 Java import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException { ObjectCodec codec = jsonParser.getCodec(); JsonNode tree = codec.readTree(jsonParser);0 码力 | 866 页 | 15.49 MB | 1 年前3
共 408 条
- 1
- 2
- 3
- 4
- 5
- 6
- 41