`
mugicoffee
  • 浏览: 37497 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

[JAVA] read a text file into String

阅读更多

one method

            String filename = "test/testfiles/testDAOUpload.xml";
            File testfile = new File(filename);
            System.out.println(testfile.getAbsolutePath());
            FileInputStream fileinput = new FileInputStream(testfile
                    .getAbsolutePath());
            int x = fileinput.available();
            byte b[] = new byte[x];
            fileinput.read(b);
            String xmlDocument = new String(b);
            System.out.println(xmlDocument);

收藏到:Del.icio.us
分享到:
评论

相关推荐

    c# read file from text

    string insertSql = "INSERT INTO YourTable (Column1) VALUES (@Value)"; using (SqlCommand command = new SqlCommand(insertSql, connection)) { command.Parameters.AddWithValue("@Value", line); command...

    File_实用案例_实现文件拷贝_FileCopy.java

    // Read a chunk of bytes into the buffer, then write them out, // looping until we reach the end of the file (when read() returns // -1). Note the combination of assignment and comparison in this ...

    Java邮件开发Fundamentals of the JavaMail API

    addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard Edition (J2SE) 1.2.x or 1.3.x. A general familiarity with object-oriented programming ...

    java使用javacsv读取csv文件 导入Mysql数据库

    String sql = "INSERT INTO your_table (column1, column2, ...) VALUES (?, ?, ...)"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { for (int i = 0; i ; i++) { pstmt.setString(i + 1, ...

    Java解析txt文件到数据库

    String sql = "INSERT INTO txt_data (column1, column2, column3) VALUES (?, ?, ?)"; try (Connection conn = DriverManager.getConnection(jdbcUrl, username, password); PreparedStatement pstmt = conn....

    PB存取超过32k的二进制文件的实例 pb 10以上

    SELECT Blob S_file INTO :FileData FROM FileUpdate WHERE S_name = :filepath USING sqlca; // 写入文件 FileWriteEx(li_File, FileData) // 关闭文件 FileClose(li_File) ``` #### 四、总结 通过上述步骤,...

    java实现excel导入数据库

    List<List<String>> excelData = ExcelReader.readExcel("path_to_your_excel_file.xlsx"); DatabaseManager dbManager = new DatabaseManager("jdbc:mysql://localhost:3306/your_database", "username", ...

    java中sqllite数据库blob数据类型的存取.docx

    String sql = "INSERT INTO your_table (column_name, blob_column) VALUES (?, ?)"; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setString(1, "some_value"); pstmt.setBytes(2, bytes); ...

    java如何上传图片到数据库

    String sql = "INSERT INTO images (img_name, img_bytea) VALUES (?, ?)"; PreparedStatement ps = conn.prepareStatement(sql); // 设置参数 ps.setString(1, file.getName()); ps.setBinaryStream(2, fis, file....

    java创建Excel并把数据导入到SQLserver

    String sql = "INSERT INTO student (name, age) VALUES (?, ?)"; PreparedStatement pstmt = con.prepareStatement(sql); pstmt.setString(1, r1); pstmt.setInt(2, Integer.parseInt(r2)); pstmt....

    java保存文件到数据库

    String sql = "INSERT INTO images (image) VALUES (?)"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { pstmt.setBytes(1, imageData); pstmt.executeUpdate(); } catch (SQLException e) {...

    个人亲测oracle触发器调用java程序

    dbms_java.grant_permission('jkt','SYS:java.io.FilePermission','c:\MO_WriteData.txt','read,write,execute,delete'); end; ``` 这将授予jkt用户对c:\MO_WriteData.txt文件的读写权限。 三、创建存储过程 下...

    java创建树和解析树(支持二叉树)

    // Convert parsed content into a tree structure } } ``` 综上所述,这些文件组合在一起,提供了一套完整的解决方案,用于从不同数据源创建和解析树结构,包括二叉树。它们利用`Node`类来表示树的节点,通过`...

    强大的免费的十六进制编辑器

    - Open file in Read Only mode (e.g. if opened by another application or to avoid unintentional modifications) - Insert file contents into file - Write block to file - Copy, move or delete block - ...

    jsonld-java:Java的JSON-LD实现

    JSONLD-Java正在寻找维护者JSONLD-JAVA 这是和的Java实现。用法从Maven <dependency> <groupId>...// Read the file into an Object (The type of this object will be a List, Map, String, Boolean

    UE(官方下载)

    You can use these functions to insert a file into the current file, delete the active file, send the file through email, or insert a string into the file at every specified increment HTML preview ...

    Java Crash Course [2016]

    But what you might not realize is that it's fairly easy to fully incorporate the essentials of Java programming once you frame that learning into a certain context (for example, practical exercises)....

    JAVA导入CSV文件

    在Java编程中,CSV(Comma Separated Values)文件是一种常用的数据存储格式,因其简单易用而被广泛应用于数据交换。CSV文件以逗号分隔各个字段,每一行代表一个记录,非常适合用来存储表格数据。当需要处理这些数据...

    java 导入excel

    List<List<String>> excelData = readExcel("path_to_your_excel_file.xlsx"); // 连接数据库并插入数据 try (Connection conn = DBConnection.getConnection()) { DBConnection.insertData(conn, excelData); ...

    java实现数据库存储图片

    String sql = "INSERT INTO mytable (picname, pic) VALUES (?, ?)"; st = con.prepareStatement(sql); File f = new File("C:/Test/a.jpg"); FileInputStream fis = new FileInputStream(f); st.setString(1, ...

Global site tag (gtag.js) - Google Analytics