java 另存为文本_Java代码复制所有文本,同时将大写字母从一个文本文件转换为另一个文本文件中的小写字母...

我遇到了编写代码时将大写字母从一个文件转换为小写字母的问题另一个。当代码运行一些名为inputtext.txt的文本文件时,它会创建输出文件,但不会转换大写文本。Java代码复制所有文本,同时将大写字母从一个文本文件转换为另一个文本文件中的小写字母

import java.io.*;

public class TextFile {

public static void main (String[] args) throws IOException {

// Assume default encoding.

// The name of the file to open for reading.

File filein = new File("inputtext.txt");

// The name of the file to open for writing.

File fileout = new File("outputtext.txt");

char CharCounter = 0;

BufferedReader in = (new BufferedReader(new FileReader(filein)));

PrintWriter out = (new PrintWriter(new FileWriter(fileout)));

int z;

while ((z = in.read()) != -1){

if (Character.isUpperCase(z)){

Character.toLowerCase(z);

}

out.write(z);

}

// Always close files.

in.close();

out.close();

}

}

2017-06-21

Rana

+0

** Character.toLowerCase(INT)** **实际收益**东西太多我愿意进一步澄清,并且这不是C/C++,我们在这里讨论,您可能希望方法改变**原始类型的值** –

+0

在将行写入输出文件之前,逐行读取并在您的行上调用String.toLowerCase。 –

+0

请详细说明,因为我对java和编程相当新颖@ShayHAned –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值